Compute Fibonacci in Ruby

Posted by yhuang
Public (Editable by Users)
Ruby
None
Edit
def fibonacci( n )
  return  n  if ( 0..1 ).include? n
  ( fibonacci( n - 1 ) + fibonacci( n - 2 ) )
end
puts fibonacci( 5 )