Power End

C Program to find list of 4 digit numbers that when raised to any power end in same 4 digits?

I have to write a C program for computer science class that finds and lists all 4 digit numbers that when raised to any power end in same 4 digits. I have no idea where to even start. Any suggestions?

Gosh, just two simple FOR NEXT loops should do it.

The inner loop is the power you're raising the number to.
The outer loop is the original number (1111 to 9999)

Sorry, I don't know the C syntax. But here's your program in BASIC, for powers up to and including 5:

FOR x = 1111 TO 9999
...FOR y = 2 TO 5
......z = x^y
......a$ = STR$(z) : b$ = STR$(x)
......IF RIGHT$(a$, 4) = RIGHT$(b$, 4) THEN
.........PRINT b$; " "; : PRINT y
......END IF
...NEXT
NEXT

If you can read BASIC, just convert this to C syntax.

Here's the output of the program above:

1,249 3
3,751 3
4,375 3
4,999 3
5,001 3
5,625 3
6,249 3
8,751 3
9,375 3
9,376 2
9,376 3
9,999 3

The first number is the original number. The second number listed is the "power."

If you check, you can see the program is working as intended. For example, 8,751^3 = 670,151,588,751. 8751 = 8751

Notice 9,376 appears twice. Pretty cool. That's probably a puzzle answer of some kind. ("What is the only four digit number that when raised to the 2nd or 3rd power..." etc.)

Find Power End On eBay Below:



Recently Purchased Power End:


gardner denver tae power end, gardner denver water jetting 431404001 power end, new nov 32t2 triplex plunger pump power end , gardner denver tee triplex power end only , new nov gaso 55t 3364 power end assembly, new gardnerdenver triplex tqc complete power end assembly pw3, new gardnerdenver tac ta3 plunger pump power end assy



Comments are closed.