From: Glenn Cadman Date: 2006-07-13T16:13:26+09:00 Subject: Recursion and Ruby As a practice to learn ruby I tried to create a recursive program (Fibonacci sequence), as a step up from "hello world", but I get a stack level too deap error, any ideas what I am doing wrong? ----------------- def fib ( n ) if n == 0 return 0 elseif n == 1 return 1 else return fib(n-1) + fib(n-2) end end 0.upto(30) { |i| puts "The #{i} Fibonacci number is #{fib(i)}" } -------------- ruby test.rb The 0 Fibonacci number is 0 test.rb:7:in `fib': stack level too deep (SystemStackError) from test.rb:7:in `fib' from test.rb:7:in `fib' from test.rb:11 from test.rb:11 pstyovm010:/home/glenn# for recursion -- Posted via http://www.ruby-forum.com/.