Fibonacci program in Ruby first=0 puts "Enter the number of terms:-" puts "The first #{n} terms of Fibonacci series are:-" Output Enter the number of terms:-
Fibonacci series is nothing but a series of numbers in which the current number is the sum of the previous two numbers
second=1
nextterm=0
n=gets.chomp.to_i
c=1
while(c<=n+1)
if(c<=1)
nextterm=c
else
puts nextterm
nextterm=first+second
first=second
second=nextterm
end
c+=1
end
4
The first 4 terms of Fibonacci series are:-
1
1
2
3
Enter the number of terms:-
6
The first 6 terms of Fibonacci series are:-
1
1
2
3
5
8
Ruby program to check whether the given number is Armstrong
Ruby program to check whether the given number is palindrome
Creating Array with Array.new(size, obj) in Ruby
Ruby program to Calculate the factorial of given number
How to create two dimensional array in ruby?
How to get index of array element in Ruby
Ruby program to reverse a string
How to add/remove elements to Array in Ruby?
Ruby program to print an array
What's the difference between a lambda, a block and a proc?
Program to Print Triangle of Numbers in Ruby
How to shuffle an array in Ruby?
Ruby program to add two integer numbers
How to Replace array elements in Ruby?
What are some of your favorite gems? What are their alternatives?
What are the various Ruby runtimes, and how are they different?
What are #method_missing and #send? Why are they useful?
How to Sort Array in Ruby?
How to Get Input with Gets in Ruby
Ruby program to generate random numbers
Ruby program to check whether the given number is prime or not
Ruby program to print Fibonacci series
how to create an array with Array.[](*args) in Ruby ?