xah icon

#2: Even Fibonacci numbers

xah | PRO | 11/23/21 06:53:35 AM UTC (Edited) | 0 ⭐ | 372 👁️ | Never ⏰ | []
Python |

280 B

|

None

|

0 👍

/

0 👎

total = 0
fibonacci = [1, 2]
temp = True
 
while temp:
    temp = sum(fibonacci[-2:])
    if temp >= 4000000:
        break
    else:
        fibonacci.append(temp)
 
 
for f in fibonacci:
    if f / 2 == f // 2:
        total = total + f
    else:
        pass
 
print(total)

Comments