Last active
January 24, 2021 12:35
-
-
Save Nadeeshyama/4e5b4d11306eab50d6c1 to your computer and use it in GitHub Desktop.
[Fibonacci Sequence] JavaScript function to output first 40 Fibonacci numbers that converge to Pi #Console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* JavaScript function to output first 40 Fibonacci and convergence to Pi | |
*/ | |
for (var p = 1, q = 1, t, i = 1; i < 41; i++) { | |
console.log('Fibonacci[%d] (%d + %d): %d; Pi: %f', i, p, q, q, (q/p)); | |
t = q; | |
q = p + q; | |
p = t; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment