Code Help and Videos >
This page introduces how the "mod"
% operator works in Java and other languages along with a few live practice code problems.
You're familiar with the 4 arithmetic operations + - * /. The
% modulus operator is an additional arithmetic operation: basically the remainder left over after division. For example, what is
73 % 10? The simplest way to think about it is, keep subtracting 10's from 73 until there's less than 10 left (3 in this case).
or35 H specialEleven old35 more20 less20 nearTen
More difficult problems that also use mod: makeBricks makeChocolate
(in python: make_bricks make_chocolate )
See also Introduction to MakeBricks
CodingBat.com code practice. Copyright 2013 Nick Parlante.