C
C
c5c52015-12-10 20:07:34
PHP
c5c5, 2015-12-10 20:07:34

Why does the php code produce such a result?

function getRemainder($a, $b) {
return $a % $b;
}
echo getRemainder(50, 7);

% (Modulo) - Integer remainder of $a divided by $b.
Answer 1 ideone.com/3LA3zU So like 7 should be and not 1

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mylistryx, 2015-12-10
@c5c5

Actually, 50% 7 = 7 and 1 in the remainder, which is what the function returned!
Check: 7 * 7 + 1 = 50.

H
holfza, 2015-12-10
@holfza

facepalm.jpg

M
Max Cohen, 2015-12-10
@Max_Cohen

This is modulo division, that is, you get the remainder. Result 1.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question