#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Remainder

Posts: 16Member
what is it?
i know it's number1 % number2, but i have no idea how to use it and why..
--Amir.
· ·

• Posts: 2,914Member
: what is it?
: i know it's number1 % number2, but i have no idea how to use it and
: why..
:
% is the modulo operator. For example:-

print 12 % 5; # prints 2
print 10 % 2; # prints 0

Essentially, it prints the remainder when you're doing division. Mathematically we say that "12 is congruent to 2 modulo 5", or:-

12 = 2 (mod 5)

Apart from the = sign is a congruency sign, e.g. 3 lines intead of 2.

Modulo is useful for various things, like wrap-round buffers.

Jonathan

###
for(74,117,115,116){\$::a.=chr};((\$_.='qwertyui')&&
(tr/yuiqwert/her anot/))for(\$::b);for(\$::c){\$_.=\$^X;
/(p.{2}l)/;\$_=\$1}\$::b=~/(..)\$/;print("\$::a\$::b \$::c hack\$1.");

· ·