I need help with a program. It is a simple program where it looks for a sequence of numbers (between 1000 and 9999) where the sum of 4 sequential numbers to the 4th power = a 4 digit number comprised of those 4 original numbers. (I know... see example).

Example: 1^4 + 2^4 + 3^4 +4^4 = 1234.

I thought I could run a "while" loop. "While total <= 9999".

Run the logic...

A = 1
B = (A+1)
C = (A+2)
D = (A+3)

I thought I could run a "while" loop. "While total <= 9999".

"if" A^4 + B^4 + C^4 + D^4 = ABCD, then print A, B, C, D. (if not, back to the loop)

A++ each time through.

The problem is that I cannot get the computer to see variables ABCD as NUMBER ABCD..... like if A, B, C, D were 1, 2, 3, 4 I need the computer to see 1234 (one thousand 2 hundred and 34).

How do I do that?

4 Years
Discussion Span
Last Post by cocopium

You gave the answer yourself!
one thousand = 1 * 1000
two hundred = 2 * 100
and 34 = 3 *10 +4
Now just add and you are done.


Yeah....the teacher tried to give me the same hint...

But by the time he answered I had already thought of that. I think I still have another problem..... but I can't think of what it is right now.

I'm going to try that out over the weekend and see what happens.


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.