Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def persistence(n):
- p = 0
- while n > 9:
- d, n = n, 1
- while d:
- d, m = divmod(d, 10)
- n *= m
- p += 1
- return p
- from functools import reduce
- from operator import mul
- def persistence_(n):
- p = 0
- while n > 9:
- n = reduce(mul, map(int, str(n)))
- p += 1
- return p
- def persistence__(n):
- p = 0
- while n > 9:
- n = reduce((lambda x, y: x * y), map(int, str(n)))
- p += 1
- return p
Add Comment
Please, Sign In to add comment