mirror of
https://github.com/correl/euler.git
synced 2024-12-17 19:16:11 +00:00
21 lines
453 B
Python
21 lines
453 B
Python
"""Find the last ten digits of 1**1 + 2**2 + ... + 1000**1000.
|
|
|
|
The series, 1**1 + 2**2 + 3**3 + ... + 10**10 = 10405071317.
|
|
|
|
Find the last ten digits of the series, 1**1 + 2**2 + 3**3 + ... + 1000**1000.
|
|
"""
|
|
|
|
def powerseries(n):
|
|
i = 1
|
|
total = 0
|
|
while i <= n:
|
|
total = total + i**i
|
|
i = i + 1
|
|
return total
|
|
|
|
def main():
|
|
val = str(powerseries(1000))
|
|
print 'Last 10:', val[-10:]
|
|
|
|
if __name__ == '__main__':
|
|
main()
|