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)