RosettaCodeData/Task/Own-digits-power-sum/FreeBASIC/own-digits-power-sum.basic
2023-07-01 13:44:08 -04:00

14 lines
310 B
Text

dim as uinteger N, curr, temp, dig, sum
for N = 3 to 9
for curr = 10^(N-1) to 10^N-1
sum = 0
temp = curr
do
dig = temp mod 10
temp = temp \ 10
sum += dig ^ N
loop until temp = 0
if sum = curr then print curr
next curr
next N