Skip to content

Instantly share code, notes, and snippets.

@MuddyBootsCode
Created April 26, 2022 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MuddyBootsCode/518e6dd3e521dc052a2414d3fe80bd8f to your computer and use it in GitHub Desktop.
Save MuddyBootsCode/518e6dd3e521dc052a2414d3fe80bd8f to your computer and use it in GitHub Desktop.
function fiboEvenSum(n) {
let a = 1;
let b = 2;
let c = 0;
let sum = 0;
if (n >=2){
sum += 2;
}
while(n > c){
c = a + b;
a = b;
b = c;
if (c % 2 === 0){
sum += c;
}
}
return sum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment