Paste Search Dynamic
Recent pastes
next term
  1. #!/usr/bin/env ruby
  2. first=0
  3. second=1
  4. nextterm=0
  5.  
  6. puts "Enter the number of terms:-"
  7. n=gets.chomp.to_i
  8.  
  9. puts "The first #{n} terms of Fibonacci series are:-"
  10. c=1
  11. while(c<=n+1)
  12.         if(c<=1)
  13.                 nextterm=c
  14.         else
  15.                 puts nextterm
  16.                 nextterm=first+second
  17.                 first=second
  18.                 second=nextterm
  19.         end
  20.         c+=1
  21. end
Parsed in 0.003 seconds