mirror of
https://github.com/correl/euler.git
synced 2024-11-24 03:00:08 +00:00
Correl Roush
715e24dcf3
excecutable code if they are called directly. git-svn-id: file:///srv/svn/euler@29 e5f4c3ec-3c0c-11df-b522-21efaa4426b5
11 lines
341 B
Python
11 lines
341 B
Python
def squarediff(n):
|
|
print 'Checking for n =', n
|
|
sumofsquares = sum([x**2 for x in range(n + 1)])
|
|
print 'Sum of squares', sumofsquares
|
|
squareofsum = sum(range(n + 1))**2
|
|
print 'Square of sum', squareofsum
|
|
print 'Difference', squareofsum - sumofsquares
|
|
|
|
if __name__ == '__main__':
|
|
squarediff(10)
|
|
squarediff(100)
|