Created
April 7, 2020 06:25
-
-
Save ayamdobhal/a0928cb337705817b8aa73fd8719992b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def persistance(N, steps=0): | |
if len(str(N)) > 1: | |
steps += 1 | |
digits = [int(x) for x in str(N)] | |
result = 1 | |
for i in digits: | |
result *= i | |
steps = persistance(result, steps) | |
return steps | |
n = int(input('Enter the multiplicative persistance: ')) | |
MP = 0 | |
count = 0 | |
while True: | |
count += 1 | |
MP = persistance(count) | |
if MP == n: | |
print('Smallest number with persistance of', n, 'is', count) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment