Hye does anyone know the formula for Fibonacci series? And can you also explain it to me? Thank You. :)
*hey
start off with 2 values; then the next value is the addition of the last 2
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, ...
thats it? alright can you help me do Pseudo Code for it?
thanks
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[]
almost ... a=b, b=c would shift it correctly
oh i see thank you sooo much :D
yep
theres some redundancy in it so its not an optimal code ...
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[]
2nd line could just as well be combined into the 3rd line too
Join our real-time social learning platform and learn together with your friends!