R Program to find remainder without using the modulus operator
In this program, You will learn how to find the remainder without using a modulus operator in R.
4 %% 5 = 4
5 %% 3 = 2
Example: How to find remainder without using modulus operator in R
{
x <- as.integer(readline(prompt = "Enter first number :"))
y <- as.integer(readline(prompt = "Enter second number :"))
while (x >= y) {
x = x - y
}
print(paste("Remainder is :", x))
}
Output:
Enter first number :5
Enter second number :2
[1] "Remainder is : 1"