Question: Write a recursive function named count_to_by that accepts integer parameters in and m and that produces output indicating how to count to n in
Write a recursive function named count_to_by that accepts integer parameters in and m and that produces output indicating how to count to n in increments of m separated by commas. For example, to count to 10 by 1 you'd say count_to_by(10, 1) The following table shows several other calls and their expected output: Call Meaning count_to_by (18,1) count to 10 by 1s count_to_by (25,4) count to 25 by 4s count_to_by (30,4) count to 30 by 4s count_to_by (34,5) count to 34 by 5s count_to_by (3,6) count to 3 by 6s count_to_by (17,3) count to 17 by 3s Output 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 1, 5, 9, 13, 17, 21, 25 2, 6, 10, 14, 18, 22, 26, 30 4, 9, 14, 19, 24, 29, 34 3 2, 5, 8, 11, 14, 17 Notice that the increment does not have to be 1, such as when counting to 25 by 4s. The count must always end at n, but notice that at will not always be possible to start counting at 1, as shown in the output when n is 30 and mis 4. But the first number should always be in the range of 1 to m inclusive. It is possible that only one number will be printed, as shown in the output when n is 3 and mis 6. Your function should raise a ValueError if either mor n is less than 1. Note that the output does not advance to the next line.
Step by Step Solution
3.38 Rating (148 Votes )
There are 3 Steps involved in it
in c incl... View full answer
Get step-by-step solutions from verified subject matter experts
