I was told to solve a problem in which I would have to find out the number of 4-digit numbers which are all composed of odd digits. I tried the following python code:
You could try something like this
def isAllOdd(num): if num < 10: return num % 2 == 1; return isAllOdd(num % 10) and isAllOdd(int(num / 10))