Thursday 21 November 2013

RUBY : Fibonacci Series

Fibonacci Series :

Here is the Fibonacci Series for the Ruby code :

def  fibonacci(n)
    n1,n2=0,1
    while n1 <=n
         print “#{n1}\n”
        n1,n2=n2,n1+n2
    end
end
fibonacci(7)

Output :

1
1
2
3
5
8
13


To know about the Fibonacci Series in detail and also to know the codes of the Fibonacci Series in various other programming languages Click Here

If the above link doesn't work go to this URL :
http://gappcode.blogspot.in/2013/11/fibonacci-series.html

No comments:

Post a Comment