J-Kit
Português

Fibonacci algorithms in computing

Fibonacci Algorithms — Recursive vs Iterative

The naive recursive implementation costs O(2ⁿ). The iterative one costs O(n). This tool uses iterative BigInt to compute F(499) in milliseconds.

Fibonacci algorithm complexity

  • Naive recursive: each call makes 2 recursive calls, creating a tree of 2ⁿ nodes. F(50) would require ~10¹⁵ operations. Not viable.
  • Iterative with BigInt: two variables and a loop — O(n) time and O(d) space where d is the digit count of F(n). F(499) has 104 digits.

Examples

F(100)

Input
n=100
Expected output
354.224.848.179.261.915.075

21 digits — impossible with float64.

F(200)

Input
n=200
Expected output
280.571.172.992.510.140.037.611.932.413.038.677.189.525

42 digits with exact precision.

Full tool FAQ

It is a sequence of integers where each term is the sum of the two preceding ones: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34… It was popularized by Leonardo of Pisa ('Fibonacci') in the 13th century.

Frequently asked questions

Why use BigInt instead of float?

Float64 has ~15–17 significant digits. F(79) already has 17 digits and exceeds float precision. BigInt has no precision limit.

Does this page replace official or professional review?

No. It helps explain the scenario and use the tool more safely, but real decisions should consider official sources, full context and qualified guidance when needed.