How many positive integers are there such that the number is equal to the sum of the cubes of its digits?
For example 1 5 3 is one of the numbers because 1 5 3 = 1 3 + 5 3 + 3 3
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
There are 5 numbers:
1 = 1 3
1 5 3 = 1 3 + 5 3 + 3 3
3 7 0 = 3 3 + 7 3
3 7 1 = 3 3 + 7 3 + 1 3
4 0 7 = 4 3 + 7 3
Since the problem is tagged under CS, do you have a cs solution?
Log in to reply
Here is a python solution:
count=0
for number in range(1,10000):
sumOfCube=0
copy=number
while number>0:
sumOfCube+=(number%10)**3
number//=10
if sumOfCube==copy:
count+=1
print count
There cannot be a 5-digit number that satisfy the criteria because the largest sum of cube of a 5-digit number is 5 ∗ 9 3 = 3 6 4 5
The answer is 5
Python has declarative sintax:
1 2 3 4 5 6 |
|
Problem Loading...
Note Loading...
Set Loading...