← Back to challenges

Exponential Fibonacci

JavaScriptHardloopsmath

Instructions

Write a function that efficiently calculates Fibonacci terms.

Examples

fibonacci(1) ➞ 1

fibonacci(2) ➞ 1

fibonacci(4) ➞ 3

fibonacci(64) ➞ 10610209857723

Notes

The input will always be a power of two.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.