Koing
Elite Member <br> Super Moderator<br> Health and F
Help!
I have this:
class Calc
{
static int fun( int i)
{
if (i==0) return 3;
else
return i*i*i+2*i+3+fun(i-1);
}
public static void main(String[] args)
{
System.out.println( "The answer is "+fun(4));
}
/* The answer is 135 */
}
I am asked
b) What is the program Calc doing?
The series I worked out is;
3, 9, 24, 60, 135
I have tried to work out what it does but I don't get it.
Any help is appreciated.
Koing
I have this:
class Calc
{
static int fun( int i)
{
if (i==0) return 3;
else
return i*i*i+2*i+3+fun(i-1);
}
public static void main(String[] args)
{
System.out.println( "The answer is "+fun(4));
}
/* The answer is 135 */
}
I am asked
b) What is the program Calc doing?
The series I worked out is;
3, 9, 24, 60, 135
I have tried to work out what it does but I don't get it.
Any help is appreciated.
Koing