sum of even numbers in Fibonacci series
Varjinth subramaniyan
1 min read
def sum_even_fibonacci(max_val):
a, b = 1, 2
sum = 0
while b <= max_val:
if b % 2 == 0:
sum += b
a, b = b, a + b
print(sum)
sum_even_fibonacci(4000000)
0
Subscribe to my newsletter
Read articles from Varjinth subramaniyan directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by