All examples By author By category About

christophermanning

Kaprekar Routine

Created by Christopher Manning

Summary

Kaprekar's constant is 6174. The Kaprekar Routine arranges four digits (zeros are appended to the number if it's less than 4 digits) in descending and ascending order, subtracts those two numbers, and repeats the process until the difference is 0 (degenrate case) or 6174 (Kaprekar's constant). The color is HSL with a scale of 0 to 300 in the domain of 1 to 7 (minimimum and maxium iterations to reach Kaprekar's constant) for hue, 1 for saturation, and .5 for lightness.

I created this because I wanted to visualize Kaprekar's constant in some way. This Wolfram MathWorld article on the Kaprekar Routine has a compelling image that is inspired by the cover of The Mathematics Teacher. From there, I decided to research some visualization techniques by recreating it with d3.js and adding some extra features (sorting, highlighting, and showing the routine).

I first heard of Kaprekar's constant after looking at the Google New York office. Apparently, there are about one-half of Kaprekar's constant Googlers there.

References