File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change 1
1
const SQ5 = 5 ** 0.5
2
- //Square root of 5
2
+ // Square root of 5
3
3
4
4
const PHI = ( 1 + SQ5 ) / 2
5
5
// definition of PHI
6
6
7
- //theoretically it should take O(1) constant amount of time as long
7
+ // theoretically it should take O(1) constant amount of time as long
8
8
// arithmetic calculations are considered to be in constant amount of time
9
- function EvenFibonacci ( limit ) {
9
+ function EvenFibonacci ( limit ) {
10
10
const highestIndex = Math . floor ( Math . log ( limit * SQ5 ) / Math . log ( PHI ) )
11
11
const n = Math . floor ( highestIndex / 3 )
12
12
return ( ( PHI ** ( 3 * n + 3 ) - 1 ) / ( PHI ** 3 - 1 ) -
13
13
( ( 1 - PHI ) ** ( 3 * n + 3 ) - 1 ) / ( ( 1 - PHI ) ** 3 - 1 ) ) / SQ5
14
14
}
15
-
16
- console . log ( EvenFibonacci ( 4e6 ) ) ;
15
+ console . log ( EvenFibonacci ( 4e6 ) )
17
16
// Sum of Even Fibonnaci upto 4 Million
You can’t perform that action at this time.
0 commit comments