0 Replies - 255 Views - Last Post: 21 July 2007 - 12:46 PM

#1 PennyBoki   User is offline

  • D.I.C Lover
  • member icon

Reputation: 55
  • View blog
  • Posts: 2,345
  • Joined: 11-December 06

Fibonacci Series

Posted 21 July 2007 - 12:46 PM

Description: Just copy the code and run it in a Ruby InterpreterPrints the series
#PennyBoki @ </dream.in.code>
puts 'Enter a number'
STDOUT.flush
string1 = gets.chomp
x = string1.to_i
puts 'The Fibonacci Series'
fib1 = 1
fib2 = 1
runner = 0
puts fib1.to_s
puts fib2.to_s
while runner<x
runner += 1
fib3 = fib1 + fib2;
fib1 = fib2;
fib2 = fib3; 
puts fib3.to_s
end

Is This A Good Question/Topic? 0
  • +

Page 1 of 1