# Thread: How to count odd digits in unsigned long number in C

1. ## How to count odd digits in unsigned long number in C

I have a question at school and I got stuck. I need to write a recursive program in c:
Code:
`int check_odd(unsigned long n){ }`

the function getting a positive natural parameter and the function need to check if this number has more than 3 odd different digits if there are more than 3 odd different digits the function need to return 0 else if there are less than 3 odd different digits the function return 1.
I need to do that in recursion. hope someone can help me with that. thank you

2. You said you got stuck. What did you try so far? The problem with just posting an answer is that you're supposed to learn how to use the return value in recursion as storage, and it's against the rules to post an answer, so...

3. What should the function return if there are exactly 3 odd digits?

4. What should the function return for input of 5555 ?

Tim S.

5. You can check if last digit is odd with the modulus operator. You can change the last digit by dividing by ten.