Animated Remainder Graph

A remainder graph provides a visual way to calculate the remainder upon dividing a given integer by a given modulus . To find the value of the remainder, take a walk on the graph starting at the 0 node. Read off the digits of from left to right. For each digit, walk the same number of steps along the black arrows, followed by a single step along a blue arrow. Continue until you follow the black arrows for the final digit. The node you end up at is the value of .
This Demonstration displays the remainder graphs for various choices of modulus. Given a positive integer, it also provides an animation of the process of walking along the graph.


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


Given a modulus , the remainder graph has node set and two distinct sets of arcs. The black set forms the cycle . The blue set leads from each node to the node .
The purpose of the blue arcs is to give a quick shortcut for digits appearing before the final digit. For example, suppose you wish to use a remainder graph to calculate . You could simply follow the black arrows for 53 steps to arrive at the correct answer, but the blue arrows let you skip some of those steps. By following the black arrows for five steps and then the blue arrow, you can immediately jump to the result of following the black arrows for 50 steps, after which you need only follow the black arrows for the remaining three steps.
The remainder graphs for certain choices of modulus also help to give a visual illustration of common divisibility tests that math students are often told to memorize. For example, for modulus 2, 5 or 10, all blue arrows point to node 0. This has the effect of causing the walk to always begin at 0 for each new digit, which means that only the final digit matters when evaluating divisibility by 2, 5 or 10.
Likewise, for modulus 3 or 9, all blue arrows form a loop that points from each node to itself. This has the effect that the blue arrows can be ignored during the walk, in which case the total distance covered on the black arrows is simply the sum of all digits. If that sum is divisible by 3 or 9, respectively, then so is the input number.
[1] P. Talwalkar, "Divisibility by 7 Test Using a Graph. Why Does It Work? Sunday Puzzle," Mind Your Decisions (blog). (Oct 11, 2017) mindyourdecisions.com/blog/2015/07/26/divisibility-by-7-test-using-a-graph-why-does-it-work-sunday-puzzle.
[2] D. Wilson, "Divisibility by 7 Is a Walk on a Graph," Tanya Khovanova's Math Blog (blog). (Oct 11, 2017) blog.tanyakhovanova.com/2009/08/divisibility-by-7-is-a-walk-on-a-graph-by-david-wilson.
[3] D. Wilson, "Divisibility by 7 Is a Walk on a Graph. II," Tanya Khovanova's Math Blog (blog). (Oct 11, 2017) blog.tanyakhovanova.com/2010/08/divisibility-by-7-is-a-walk-on-a-graph-ii-2.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-Step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2018 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+