Created
March 21, 2019 14:10
-
-
Save ficoos/6dae9e406e83d0eaa119157643d02fb4 to your computer and use it in GitHub Desktop.
Multiplication persistance
This file contains 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 per(n, print_steps=False): | |
steps = 0 | |
while n >= 10: | |
sum = 1 | |
while n > 0: | |
sum *= n % 10 | |
n //= 10 | |
n = sum | |
steps += 1 | |
if print_steps: | |
print(f"{steps} - {n}") | |
return steps | |
print(per(277777788888899, True)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment