Geometric Progression using Recursion (Java)

I have an assignment for class where I need to write a method which calculates a Geometric progression for n integers using recursion.

The value of n is received from the user.

public static float Geometric(float n)



return 1;



if(n == 1)



return (n * Geometric(n-1));



The code works fine, until the value of n exceeds 34. Then, the method starts returning wrong answers. I'm assuming it has to do with the maximum value that a float can hold.

Is there a way to calculate/store values that exceed the maximum value of...

Read More »

By: StackOverFlow - Tuesday, 6 November

Related Posts