Determine if a number is perfect digit to digit
This commit is contained in:
parent
b137d99a96
commit
cd096b8551
1 changed files with 11 additions and 0 deletions
11
python/pdtd.py
Normal file
11
python/pdtd.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
for num in range(1, 5001):
|
||||||
|
total = 0
|
||||||
|
rem = num
|
||||||
|
|
||||||
|
while rem > 0:
|
||||||
|
digit = rem % 10
|
||||||
|
total += pow(digit, digit)
|
||||||
|
rem //= 10
|
||||||
|
|
||||||
|
if total == num:
|
||||||
|
print(total)
|
Loading…
Reference in a new issue