RosettaCodeData/Task/Munchausen-numbers/AppleScript/munchausen-numbers-3.applescript
2023-07-01 13:44:08 -04:00

14 lines
353 B
AppleScript

set MunchhausenNumbers to {}
repeat with i from 1 to 5000
if (i > 0) then
set n to i
set s to 0
repeat until (n is 0)
tell n mod 10 to set s to s + it ^ it
set n to n div 10
end repeat
if (s = i) then set end of MunchhausenNumbers to i
end if
end repeat
return MunchhausenNumbers