Archive
Python: Self Power
Python: Self Powers
Problem No.48 on ProjectEuler
Another easy task in Problem No.48. We have to find the power of each number to itsefl in the range of 1 to 1000 and get the sum of all numbers, then to find the last ten digits of the series.
In this Task we will save the powers in a set name powers then we run a for loop
to get the sum of all elements in the lest, later will reade the last ten digits.
Enhancment In this problem I will not do any more than solving the problem, but if we want to enhance the project, we can ask the user to enter a range and we perform the function on that range of numbers.
![]() |
![]() |
The Code:
powers=[]
def get_power(num):
powers.append(num**num)
for x in range(1,1001):
get_power(x)
sum=0
for each in powers:
sum=sum+each
print(powers)
print (‘the sum is ‘,sum)