Project Euler 2: Even Fibonacci numbers Solution
1const solution = () => {2 const LIMIT = 4 * 1e634 function* fib() {5 let a = 06 let b = 17 while (1) {8 yield a9 ;[a, b] = [b, a + b]10 }11 }1213 const fibGen = fib()14 let res = 015 while (1) {16 const val = fibGen.next().value17 if (val > LIMIT) break18 if (val % 2 === 0) res += val19 }20 console.log(res)21}2223solution()
Comments
Loading comments...
Tags
projecteuler
Apply and earn a $2,500 bonus once you're hired on your first job!
Clients from the Fortune 500 to Silicon Valley startups
Choose your own rate, get paid on time
From hourly, part-time, to full-time positions
Flexible remote working environment
A lot of open JavaScript jobs!!
Fact corner: Referred talent are 5x more likely to pass the Toptal screening process than the average applicant.
Still hesitate? Read HoningJS author's guide on dealing with Toptal interview process.
Next Post
Project Euler 1: Multiples of 3 and 5
Mar 14, 2021