Answered step by step
Verified Expert Solution
Question
1 Approved Answer
int modulus (number, base) { The modulus operation returns the unit value of a number in a given base. For example: In base 10 ,
int modulus (number, base)
{
The modulus operation returns the unit value of a number in a given base. For example: In base 10 , the unit value of 237 is 7.(237%10=7) In base 2 , the unit value of 1023 is 1 . (1023%2=1) In base 8 , the unit value of 6 is 6.(6%8=6) Write a recursive function in that will calculate the modulus of two positive inputs (the number and the base). Note: you may only use addition and subtraction - you must not use multiplication, division, modulus, or any other methods in your solution, and you will not receive any credit for a non-recursive solution. Hint: use repeated subtraction. For example, the following statements would lead to the underlined output: Example 1: print(modulus(237,10));7 Example 2: print(modulus(1023,2));1 Example 3: print(modulus(6,8));6 Note: you may assume two positive inputs - no error checking of inputs is requiredStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started