Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • fibonaci series using arrays in Ruby

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 178
    Comment on it

    It is a series of Whole number where we have to find sum of the two preceding numbers. It Begins with 0 and 1, the sequence goes like this 0,1,1, 2, 3, 5, 8, 13, 21, 34, etc. using the formula n = n(-1) + n(-2), where the n(-1) is the the last number before n and n(-2) is the second last one before n in the series.

    Example

    f = Array.new
    f[0] = 0
            f[1] = 1
    
            for i in 2..7
                    f[i] = f[i-1] + f[i-2]
    end
    for i in 0..7
    puts "#{f[i]}"
    end
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: