I'm trying to solve a problem using recursion that would be pretty verbose if I used 'if' statements. I'm looking to see how many times a CONST = 50 is in n. I want to return the number of occurrences that 50 is in n. I know it's straight forward but I want to use recursion to accomplish this, that is not straight forward to me. The conditions are like:
0 < n == 50 -> 1 instance
50 < n <= 100 -> 2 instance
100 < n <= 150 -> 3 instance
150 < n <= 200 -> 4 instance
200 < n <= 250 -> 5 instance
...
...
...
Below is what I started, but I got stuck:
def num_of_times(n)
""" (int) => int
when n is entered count 1 for every 50 found. If any number is over 50, yet does not
equal another 50 (e.g. n = 60; 60 - 50 = 10; 50 -> 1; 10 -> 1) will call for a count, which would be a count of 2 in this case.
>>>num_of_times(60)
2
>>>num_of_times(200)
4
"""
count = 0
if n > 0 and n == 50:
count += 1
elif n > 50:
""" Here is where my thinking is going to sleep"""
...
...
...
Thanks in advance for any help offered.
1 + ((n-1) / 50)math.ceil(n/50.0).