Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Recursive function conversion

Name: Anonymous 2011-10-25 17:09

I'm taking discrete structures for my CS degree and so far it hasn't been a problem. But this question has me stumped.

f(0)=1, f(1)=0, f(2)=2, f(n)=2f(n-3) when n>= 3
So the pattern comes out like this: 1, 0, 2, 2, 0, 4, 4, 0...

I can't figure out how to convert it to a non-recursive function. Any suggestions?

Name: sil 2011-10-26 5:58

f(3k+1)=0;
f(3k)=2^k;
f(3k+2)=2^(k+1);
hope it right:D

Don't change these.
Name: Email:
Entire Thread Thread List