Ask your own question, for FREE!
Mathematics 16 Online
OpenStudy (anonymous):

Hye does anyone know the formula for Fibonacci series? And can you also explain it to me? Thank You. :)

OpenStudy (anonymous):

*hey

OpenStudy (amistre64):

start off with 2 values; then the next value is the addition of the last 2

OpenStudy (amistre64):

a,b a,b,(a+b) a,b,(a+b), (a+b)+b a,b,(a+b), (a+b)+b, (a+b)+(a+b)+b, ...

OpenStudy (anonymous):

thats it? alright can you help me do Pseudo Code for it?

OpenStudy (anonymous):

thanks

OpenStudy (amistre64):

var Fib = new Array() var a=input1, b=input2 Fib[0] = a, Fib[1] = b for (x = 2 to k; x=x+1) { var c=a+b b=a, a=c Fib[x]=c } display Fib[]

OpenStudy (amistre64):

almost ... a=b, b=c would shift it correctly

OpenStudy (anonymous):

oh i see thank you sooo much :D

OpenStudy (amistre64):

yep

OpenStudy (amistre64):

theres some redundancy in it so its not an optimal code ...

OpenStudy (amistre64):

var Fib = new Array() var a=input1, b=input2 Fib[0] = a, Fib[1] = b for (x = 2 to k; x=x+1) { Fib[x] = Fib[x-1] + Fib[x-2] } display Fib[]

OpenStudy (amistre64):

2nd line could just as well be combined into the 3rd line too

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!