Skip to content

Instantly share code, notes, and snippets.

@MrBean83
Last active December 20, 2015 10:31
Show Gist options
  • Select an option

  • Save MrBean83/6116094 to your computer and use it in GitHub Desktop.

Select an option

Save MrBean83/6116094 to your computer and use it in GitHub Desktop.
#FibonacciSequence
def is_fibonacci?(i)
n = i * Math.sqrt(5)
n1 = Math.sqrt((5*(i**2)+4))
n2 = Math.sqrt((5*(i**2)-4))
if (i == 1 || i == 0)
return true
elsif (n1 % 1 == 0) || (n2 % 1 == 0)
return true
else
return false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment