0
What's the use of modulo?
Like int x = 5; int y = 25; int res = y % x; System.out.println(res) Someone explain?
15 Respostas
+ 7
module returns reminder value
y % x = 25 % 5 = 0
Because we can divide 25 with 5
If y = 26 then 26 % 5 = 1 because 5 * 5 + 1 = 26
+ 7
Think of it like in elementary school maths:
If we divide 7 by 2, we get 3 plus a remainder of 1. The modulo operator gives us this remainder.
+ 4
Walie Ojwallah 2%5
= 2, not 1
+ 3
The operator of the remainder of the number %
(for example: 17 % 3 = 2)
1. Take the nearest number when divided by 3 would be zero. That's apparently 15
2. Subtract 15 from 17 and the result is your answer.
+ 2
3%8 = ?
+ 1
Modulo division gives us the ability to determine multiples of let's say 5:
5, 10, 15, 20, 25
ALI Moussa Kadjalla this is not the first time I have come across this answer of yours with the incorrect formula of division modulo.
Here is a correct calculation of division modulo:
a%b == a-a//b*b
+ 1
Rather than divison (which gives quotient), modulo gives remainder as the ans
As
6%5 gives 1(remainder)
8%3 gives 2(remainder
+ 1
Like
num = int ( input ( "Enter an integer:"))
if num % 2 == 0:
print ( num,"is EVEN number.")
else :
print (num,"is ODD number.")
0
the operation modulo(%) finds the rest or the rest signed after the division of a number by another (called the module of the operation).
Given two positive numbers, a and n, a modulo n (a%n, abbreviated as a mod n) is the rest of the Euclidian division of a by n, where a is dividend and n is divider.
This operation can satisfy also the following formula a*(a//b)+(a%b)
26%5
Almost 26=5*5+1
26%5=1
0
The modulo returns the remainder of a division
25 %5 gives us 5 remainder 0
That 0 is the result of a modulo
0
Solo ok
0
Because modulo operator is used get the remainder.
0
So modulo means the remainder after a division like when you dive 10%5 then remainder is 0 because 5 is divide 10 and nothing else is remain.
- 1
Mifuko gives the remainder value in an operation and is denoted by % which is commonly known as the percentage sign.
Example:
print(2 % 5)
= 1
Here 1 is the remainder after the calculation. Meaning that here we don't divide everything. If there be a remainder then must be noted.