+ 1
Ok then similarly to c here % produces remainder but using // 2 times we get quotient
is that correct
2 ответов
+ 13
// This operation is known as floor division (gives the quotient as whole number)
/ gives the quotient as float form
% gives remainder
5/2 is 2.5
5//2 is 2
5%2 is 1
0
Every integer can be written in the form of n = p*q + r where p is a positive integer, q is an integer and r < |q| (absolute value).
When doing n % q the answer is r, when doing n // q the answer is p. So n == (n // q)*q + (n % q) will return true.