# How can I do this program?

• 11-12-2010, 03:31 PM
Sorena
How can I do this program?
Write a program that will find all the three digit natural numbers that are equal to the sum of the cubes of their digits. Maximum 3 digit number is 999. What is the first?
• 11-12-2010, 03:42 PM
funnyboy
To multiply all digits divide the number by ten and store the leftover in another variable (by using the % operator). Then divide the left number by ten again and so on.
• 11-12-2010, 04:09 PM
JosAH
Quote:

Originally Posted by Sorena
Write a program that will find all the three digit natural numbers that are equal to the sum of the cubes of their digits. Maximum 3 digit number is 999. What is the first?

153; do you really lack the imagination to come up with the condition:

Code:

`        if (100*a+10*b+c == a*a*a+b*b*b+c*c*c)`
in a triple nested loop for values of a in [1,9] and values of b and c in [0,9];
... if so, programming is not for you.

kind regards,

Jos
• 11-13-2010, 02:49 AM
al_Marshy_1981
I hope this was a mathematic course....