Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def prod(n):
- if n == 0:
- return 1
- return (n % 10) * prod(n // 10)
- def nr_digits(n):
- if n == 0:
- return 1
- if n // 10 != 0:
- return 1 + nr_digits(n // 10)
- else:
- return 1
- def max_digit(n):
- if n == 0:
- return 0
- return max(n % 10, max_digit(n // 10))
- def nr_even_digits(n):
- if n == 0:
- return 1
- if n // 10 != 0:
- if ((n % 10) % 2) == 1:
- return nr_even_digits(n // 10)
- else:
- return 1 + nr_even_digits(n // 10)
- else:
- if ((n % 10) % 2) == 1:
- return 0
- else:
- return 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement