Page 1 of 1

write a code using recursive function

PostPosted: Thu Jul 01, 2010 4:26 pm
by darvin13
my problem:
i have to write a code using recursive function about arithmetic series in multiplication.

example:

the user will input two integers the length of the output and the difference, the output must start to 2.

Enter the length: 5 //this is not fixed
Enter the difference: 2 //this is not fixed

the output must be: 2 4 8 32 256

if you know the program please help me..
thanks :)

Re: help me..

PostPosted: Thu Jul 01, 2010 4:50 pm
by Robert Sample
What have you written so far? Where are you stuck? Or are you expecting us to write your code for you?

And what, exactly, are the rules for taking your input to generate your output? For the example you give, 4 = 2 x 2, 8 = 4 x 2, 32 = 8 x 4, 256 = 32 x 8 so your multipliers are not even constant. Mathematically, an arithmetic progression has constant differences, not multiplications -- geometric progressions multiplies each term by a constant value to derive the next term. So you don't have a geometric progression, either. And whatever series you're supposed to be producing, recursion is pretty much not the way to do it -- recursion is good for factorials but not progressions.

Re: help me..

PostPosted: Thu Jul 01, 2010 6:38 pm
by enrico-sorichetti
the sequence is like a Fibonacci one with multiplication instead of the sum
every element is the product of the two preceding elements

Re: help me..

PostPosted: Fri Jul 02, 2010 12:52 am
by dick scherrer
Hello,

You have now started 4 topics with the same question. . . :(

One more and they will all be deleted. . .

d