Reputation: 237
If the input is a number, how can I write a procedure that checks every digit and produces an output equal to the number of odd digits in this number?
I'm thinking about turning the number into a list first, but I'm trying to think of an easier solution.
Also, we're not allowed to use "odd?". So instead of using "odd?" to check whether or not a digit is odd, we can use "quotient"
Upvotes: 1
Views: 108
Reputation: 3670
Rather than convert to a string like in marekful's comment, try recursively taking off the most significant digit at a time using the mod operation. Then, you can use the quotient function to test for odd or even.
Upvotes: 1