Home > Problem, Projects/Experiments, Python > Python: Self Power

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)






Follow me on Twitter..



  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s