Skip to content

Instantly share code, notes, and snippets.

@ficoos
Created March 21, 2019 14:10
Show Gist options
  • Save ficoos/6dae9e406e83d0eaa119157643d02fb4 to your computer and use it in GitHub Desktop.
Save ficoos/6dae9e406e83d0eaa119157643d02fb4 to your computer and use it in GitHub Desktop.
Multiplication persistance
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