Project Euler - Problem 28


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #!/usr/bin/python
  2.  
  3. # Project Euler - Problem 28
  4.  
  5. # Find the sum of the diagonals of a 1001x1001 spiral
  6.  
  7.  
  8.  
  9. n = 1001
  10. sum = 1
  11.  
  12. for x in range(1001,1,-2):
  13. sum += ((x**2) << 2) - (6*x) + 6
  14.  
  15. print sum

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.