Problem 1: Number of Six (100pts)
Write a recursive function number_of_six
that takes a positive integer x
and returns the number of times the digit 6 appears in x
.
Use recursion - the tests will fail if you use any assignment statements.
def number_of_six(n):
"""Return the number of 6 in each digit of a positive integer n.
>>> number_of_six(666)
3
>>> number_of_six(123456)
1
>>> from construct_check import check
>>> # ban all assignment statements
>>> check(HW_SOURCE_FILE, 'number_of_six',
... ['Assign', 'AugAssign'])
True
"""
"*** YOUR CODE HERE ***"