### Thread: Need help with program

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Sep 2012
Posts
1
Rep Power
0

#### Need help with program

Ok so the assignment is:
"Write a program that asks for an integer input ‘n’ and print all integer numbers of n-digits for which the sum of the
digits of the number, to the power of three, is equal to the number itself.

For instance, for n=2, check all numbers in the range of 10 – 99. e.g 37 = 3^3+7^3"

And I'd like some help on how to do this with explanation.

Yours sincerely, fireflashx32

• b49P23TIvg agrees : I agree that the comma of "number, to" implies that the equation should be pow((sum of digits of n),3)==n . Confusing.
2. So what bit is confusing you?

- Reading in a number n ?
- counting from pow(10,n-1) to pow(10,n)-1 ?
- extracting digits from x ?
- calculating the sum of two cubes ?

Show us what steps you CAN achieve for yourself, then post a question about your code.

This isn't a homework dumping site.
3. Interesting problem. We might ask

Are there a finite number of such numbers?

How does the answer change if we express n in a different base?
4. No Profile Picture
Contributing User
Devshed Intermediate (1500 - 1999 posts)

Join Date
Feb 2004
Location
San Francisco Bay
Posts
1,939
Rep Power
1317
Originally Posted by b49P23TIvg