def fact(n): """Calculates n!""" if n == 0: return 1 else: return n * fact(n - 1) def sum_digits(n): """Calculates the sum of the digits `n` >>> sum_digits(8) 8 >>> sum_digits(18) 9 >>> sum_digits(2018) 11 """ if n < 10: return n else: all_but_last, last = n // 10, n % 10 return sum_digits(all_but_last) + last def count_up(n): """Prints the numbers from 1 to n. Assume `n` is positive. >>> count_up(1) 1 >>> count_up(2) 1 2 >>> count_up(4) 1 2 3 4 """ if n == 1: print(1) else: count_up(n - 1) print(n) def is_even(n): if n == 0: return True return is_odd(n - 1) def is_odd(n): if n == 0: return False return is_even(n - 1) def has_eight(n): """Check is the number contains an 8. >>> has_eight(8) True >>> has_eight(18) True >>> has_eight(123456790) False >>> has_eight(181) True """ if n == 0: return False all_but_last, last = n // 10, n % 10 return last == 8 or has_eight(all_but_last)