Advertisement
xah

#2: Even Fibonacci numbers

xah
Jan 6th, 2020 (edited)
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. total = 0
  2. fibonacci = [1, 2]
  3. temp = True
  4.  
  5. while temp:
  6.     temp = sum(fibonacci[-2:])
  7.     if temp >= 4000000:
  8.         break
  9.     else:
  10.         fibonacci.append(temp)
  11.  
  12.  
  13. for f in fibonacci:
  14.     if f / 2 == f // 2:
  15.         total = total + f
  16.     else:
  17.         pass
  18.  
  19. print(total)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement