From 9e6fe4bdaff04d7abf594e3125d5d45abba2d23e Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Sat, 10 Oct 2020 18:18:25 +0530 Subject: [PATCH] Fixed Indendation Issues --- Project-Euler/Problem2.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Project-Euler/Problem2.js b/Project-Euler/Problem2.js index 275686d87..cc6f2cea0 100644 --- a/Project-Euler/Problem2.js +++ b/Project-Euler/Problem2.js @@ -1,17 +1,16 @@ const SQ5 = 5 ** 0.5 -//Square root of 5 +// Square root of 5 const PHI = (1 + SQ5) / 2 // definition of PHI -//theoretically it should take O(1) constant amount of time as long +// theoretically it should take O(1) constant amount of time as long // arithmetic calculations are considered to be in constant amount of time -function EvenFibonacci(limit) { +function EvenFibonacci (limit) { const highestIndex = Math.floor(Math.log(limit * SQ5) / Math.log(PHI)) const n = Math.floor(highestIndex / 3) return ((PHI ** (3 * n + 3) - 1) / (PHI ** 3 - 1) - ((1 - PHI) ** (3 * n + 3) - 1) / ((1 - PHI) ** 3 - 1)) / SQ5 } - -console.log(EvenFibonacci(4e6)); +console.log(EvenFibonacci(4e6)) // Sum of Even Fibonnaci upto 4 Million