025 1000-digit Fibonacci number -- v2.sf 353 B

123456789101112131415161718192021
  1. #!/usr/bin/ruby
  2. # Daniel "Trizen" Șuteu
  3. # Date: 05 November 2017
  4. # https://github.com/trizen
  5. # https://projecteuler.net/problem=25
  6. # Runtime: 0.302s
  7. func fib_len(n, base=10) {
  8. static S = (sqrt(1.25) + 0.5)
  9. static T = (1 - S)
  10. static W = (S - T)
  11. 1 + ilog((S**n - T**n) / W, base)
  12. }
  13. say (^Inf -> first_by {|n| fib_len(n) == 1000 })