Skip to content

Commit 10f664d

Browse files
Abhishek JainAbhishek Jain
authored andcommitted
ESLINT fixes
1 parent 6df59cd commit 10f664d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

Project-Euler/Problem2.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
const SQ5 = 5 ** .5; // Square root of 5
2-
const PHI = (1 + SQ5) / 2; // definition of PHI
1+
const SQ5 = 5 ** 0.5
2+
//Square root of 5
33

4-
//theoretically it should take O(1) constant amount of time as long
5-
// arithmetic calculations are considered to be in constant amount of time.
4+
const PHI = (1 + SQ5) / 2
5+
// definition of PHI
66

7+
//theoretically it should take O(1) constant amount of time as long
8+
// arithmetic calculations are considered to be in constant amount of time
79
function EvenFibonacci(limit) {
8-
const highestIndex = Math.floor(Math.log(limit * SQ5) / Math.log(PHI));
9-
const n = Math.floor(highestIndex / 3);
10-
return ((PHI ** (3 * n + 3) - 1) / (PHI ** 3 - 1)
11-
- ((1 - PHI) ** (3 * n + 3) - 1) / ((1 - PHI) ** 3 - 1)) / SQ5;
10+
const highestIndex = Math.floor(Math.log(limit * SQ5) / Math.log(PHI))
11+
const n = Math.floor(highestIndex / 3)
12+
return ((PHI ** (3 * n + 3) - 1) / (PHI ** 3 - 1) -
13+
((1 - PHI) ** (3 * n + 3) - 1) / ((1 - PHI) ** 3 - 1)) / SQ5
1214
}
1315

1416
console.log(EvenFibonacci(4e6));
15-
// Sum of Even Fibonnaci upto 4 Million
17+
// Sum of Even Fibonnaci upto 4 Million

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy