tbug511622.nim 249 B

12345678910111213
  1. discard """
  2. output: "3"
  3. """
  4. import math
  5. proc FibonacciA(n: int): int64 =
  6. var fn = float64(n)
  7. var p: float64 = (1.0 + sqrt(5.0)) / 2.0
  8. var q: float64 = 1.0 / p
  9. return int64((pow(p, fn) + pow(q, fn)) / sqrt(5.0))
  10. echo FibonacciA(4) #OUT 3