Modulo using Recursion
In this lesson, we will learn about the modulo operation and how to implement it using recursion.
What is the modulo operation?
The modulo operation (abbreviated as mod) finds the remainder after the division of one number, the dividend, by another number, the divisor.
Below is an image that illustrates how to revise the concept of the remainder using a basic division example:
In the example above, we have divided 14, the dividend, by 4, the divisor, which results in 3 as the quotient and 2 as the remainder.
If we were to use a mod function, it would be implemented as follows:
We read this as 14 mod 4 is equal to 2.
💡 Note
If the dividend is fully divisible by the divisor, the remainder is ...
Access this course and 1400+ top-rated courses and projects.