Skip to content

Instantly share code, notes, and snippets.

@miura1729
Created October 13, 2011 11:12
Show Gist options
  • Save miura1729/1283989 to your computer and use it in GitHub Desktop.
Save miura1729/1283989 to your computer and use it in GitHub Desktop.
detect fib number test
PHI = (Math.sqrt(5.0) + 1) / 2
def rfib(a)
la = Math.log(a)
lp = Math.log(PHI)
l5 = Math.log(Math.sqrt(5.0))
(la + l5) / lp
end
(1..100).each do |i|
p "#{i} #{rfib(i)}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment