Guest User

Untitled

a guest
Jun 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. x, y = 0, 1
  2. a = []
  3. while 1:
  4. if x % 2 == 0:
  5. if x >= 4000000:
  6. break;
  7. else:
  8. a.append(x)
  9. x, y = y, x + y
  10.  
  11. for n in a:
  12. print str(n) + "\n"
  13.  
  14. print 'total: ' + str(sum(a))
  15.  
  16.  
  17. masticore@ubuntu:~/portfolio/python/projecteuler$ python 2.py
  18. 0
  19.  
  20. 2
  21.  
  22. 8
  23.  
  24. 34
  25.  
  26. 144
  27.  
  28. 610
  29.  
  30. 2584
  31.  
  32. 10946
  33.  
  34. 46368
  35.  
  36. 196418
  37.  
  38. 832040
  39.  
  40. 3524578
  41.  
  42. sum: 4613732
Add Comment
Please, Sign In to add comment