Skip to content

Commit b8e2012

Browse files
authored
Create EvenFibonacciNumbersSum.js
1 parent 462b50a commit b8e2012

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

EvenFibonacciNumbersSum.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function fiboEvenSum(n) {
2+
let a = 0,b = 1,result = b, sum=0;
3+
for(let i=0; i< n; i++){
4+
result = a + b
5+
a=b;
6+
b=result;
7+
if(result % 2 === 0){
8+
sum +=result
9+
}
10+
}
11+
12+
13+
return sum;
14+
}
15+
16+
fiboEvenSum(10);

0 commit comments

Comments
 (0)