mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 17:34:43 +00:00
17 lines
287 B
Nim
17 lines
287 B
Nim
discard """
|
|
file: "tbug511622.nim"
|
|
output: "3"
|
|
"""
|
|
import StrUtils, Math
|
|
|
|
proc FibonacciA(n: int): int64 =
|
|
var fn = float64(n)
|
|
var p: float64 = (1.0 + sqrt(5.0)) / 2.0
|
|
var q: float64 = 1.0 / p
|
|
return int64((pow(p, fn) + pow(q, fn)) / sqrt(5.0))
|
|
|
|
echo FibonacciA(4) #OUT 3
|
|
|
|
|
|
|