Python: This assignment requires one file named program121.py containing a main
ID: 3764345 • Letter: P
Question
Python:
This assignment requires one file named program121.py containing a main function and a recursive function named findmod. The findmod function should compute a mod b but without using the % operator.
In main:
prompt the user to enter two positive integers.
call the findmod function with these integers as arguments.
print its returned value.
The findmod function, findmod(integer1, integer2), must recursively calculate the remainder and then return it.
SAMPLE OUTPUT
Enter a positive integer 17
Enter another positive integer 5
The remainder is 2
SAMPLE OUTPUT
Enter a positive integer 30
Enter another positive integer 8
The remainder is 6
Explanation / Answer
num = input("Enter a number: ") div = input("Enter a divisor: ") while num >= div: num -= div print num
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.