Kaprekar’s constant

A student talked about Kaprekar’s constant (6174) during their my favorite presentation.
Really cool.

Steps (from wikipedia):

  1. Take any four-digit number, using at least two different digits. (Leading zeros are allowed.)
  2. Arrange the digits in descending and then in ascending order to get two four-digit numbers, adding leading zeros if necessary.
  3. Subtract the smaller number from the bigger number.
  4. Go back to step 2.

Here’s an example (also from wikipedia):

For example, choose 3524:

5432 – 2345 = 3087
8730 – 0378 = 8352
8532 – 2358 = 6174

Fun right? Also fun to program, here’s the python code that tries every number from 1000 to 10000, and counts how many steps it takes to get to 6174 and puts the results in a csv file:

def largest(nstr):
    if (len(nstr) == 0):
        return ""
    elif (len(nstr)==4) and (nstr[0] == nstr[1] == nstr[2] == nstr[3]):
        return "7641"
    digit = -1
    index = 0
    for i in range(0,len(nstr)):
        if (digit < int(nstr[i])):
            digit = int(nstr[i])
            index = i
    return str(digit) + largest(nstr[0:index]+nstr[index+1:len(nstr)])
def kaprekarSteps(n):
    count = 0
    nstr = str(n)
    while (n != 6174):
        l = int(largest(str(nstr)))
        lstring = str(l)
        s = int(lstring[::-1])
        n = l - s
        nstr = str(n)
        while (len(nstr) < 4):
            nstr = "0" + nstr
        count += 1
    return count
f = open('kaprekar.csv','w')
c = 1000
while (c < 10000):
    f.write(str(c)+ "," + str(kaprekarSteps(c)) + "\n")
    c += 1


Euclid GCD

I saw this toot by Matt yesterday morning and I loved the visual of the color based on the number of steps of Euclid’s GCD algorithm. The algorithm is pretty straightforward and it’s a nice example for either using recursion or using a loop. The coloring is fun to mess with too. The coding went quickly for me because I already had the code for breaking a 1D pixel array (why processing??) into x and y coordinates.
There’s two variations:
Here’s the link for the GCD steps version.
And here’s the link for the GCD version where the closer the GCD is to the minimum of x and y, the more white the pixel is.
Here’s the recursive algorithm:

int euclidGCD(int x, int y)
  if (y == 0)
    return x;
  else if (x >= y && y > 0)
    return euclidGCD(y,(x%y));
    return euclidGCD(y,x);

Here’s the loop algorithm to count the number of steps:

int euclidGCDsteps(int x, int y)
  int t;
  int steps = 0;
  if (x >= y)
    while (y != 0)
      t = y;
      y = x % y;
      x += t;
    return euclidGCDsteps(y,x);
  return steps; 

My Favorite for the Students

Let me know if these are things that interest you as a teacher of children:

  • You want the students to find your subject interesting.
  • You want the students to investigate your subject in their own time, like an adult would do.
  • You want the students to continue to develop their presentation skills.
  • You want the students to pique the interest of the other students in the class in your subject.
  • You want to expose the students in your class to a diverse set of ideas, opinions, and experiences.

When I (briefly) attended Twitter Math Camp last year, I really enjoyed the My Favorite section of the conference. This is a section where teachers came forward and presented something that they liked that they thought the other teachers would be interested in. These included activities, strategies, etc. Pretty much whatever the presenter thought the other teachers would enjoy. They had about 5-10 minutes to present.

To co-opt this My Favorite structure to my classroom, I asked every student in all of my classes to present one thing that they found interesting about math.

Here’s the document that I gave the students:

How’d it go?

Great! I loved it, and I (think) the kids loved it. We had so many different and interesting topics. Here’s a quick subset of the topics that were covered in three of the classes:

Fibonacci and Bartok
Friendship Paradox
Volleyball winning odds
Pi Cupcakes
Vortex Math
Birthday Paradox
Chaos Theory
Hairy Ball Theorem
3D Polyhedra
Pythagorean Thm
Riot Theory
Monty Hall Paradox
Pappus of Alexandria Thm
Golf Handicap
Quad Midpoints make Parallelogram
Kaprekar’s Constant
Number Trick
4 color theorem
Diving Scoring
Brouwers fixed point theorem
P vs NP
Mole Train Woot Woot
Sound and Sine
Fourier Transforms
Golden Ratio
Font Layout and Yearbook
Binary Numbers
Fermat’s Last Theorem
Rule of 72
Mobius Strip
P vs NP
Golden Ratio and Phi
Mandelbrot Fractal
Reuleaux Polygons
Graham’s Number
Pascal’s Triangle
Schwarz lantern
Monty Hall
Math (and Physics) of Bowling
What’s faster, going up or going down?

Only recognize about 2/3rds of them? Me too. It was awesome seeing the different mathematics that was discussed in our classes. What was the percent of topics that lined up with any of the final exams? I’d say under 5%.

Do you have 2-5 min to spare 30 or so times per class per year with very little burden of prep on the teacher? I would bet that you do.

Lizard Grow

My son was given this lizard as a big brother gift (can’t find online link to product, but here’s a similar toy).

Original Size


Size After 2 Day Soak


Before Measurements

Left image
Length: 905 pixels
Width (between front feet): 275 pixels
1 inch: 90 pixels
Right image
Height: 150 pixels
1 inch: 115 pixels

After Measurements

Left image
Length: 1014 pixels
Width (between front feet): 292 pixels
1 inch: 60 pixels
Right image
Height: 200 pixels
1 inch: 98 pixels


Original Length: 10.06″
Original Width: 3.06″
Original Height: 1.30″

After Length: 16.90″ (increase of 68%)
After Width: 4.87″ (increase of 59%)
After Height: 2.04″ (increase of 57%)



Calculations Take 2

Volume of box that would just contain original lizard: 10.06 * 3.06 * 1.30 = 40.02 cubic inches
Volume of box that would just contain soaked lizard: 16.90 * 4.87 * 2.04 = 167.90 cubic inches (increase of 319%)

Conclusion Take 2

Thoughts? Did I mess up?

More Questions

  • How big would it be if the volume *did* increase by 600%?
  • How big would the lizard be if it grew 1000%? 10,000%?
  • How big would the lizard have grown if it just barely fit in *your* classroom?

M&M’s Mega


3x the Chocolate?

What a great Calculus activity (hint: rotational volumes).
Cross sections with an exacto:



M&M Mega


What shape fits best? Click on image to get directly to the desmos interactive.
Pretty good fit.
Here’s the data for each type. I used a caliper to measure the dimensions.

To account for the candy shell you can measure pixels in an image manipulation program. If you’d like to follow along at home, the M&M Mega has a thickness of 404 pixels, and the chocolate only (no shell) has a thickness of 333 pixels. The regular M&M has a thickness of 251 pixels, and a chocolate thickness of 210 pixels.

You have enough information to do some damage, go ahead and see if the M&M’s Mega truly have 3x the chocolate of the regular M&M’s.


M&M Mega volume of 1,423 mm^3.
Regular M&M volume of 474.8 mm^3.

Fun. Great activity for calculus.
Phew, no fox news.

Daily Desmos 3.0

Hello all, we’re looking to reinvigorate the Daily Desmos project and we’re looking for new contributors (and that means you!). We’re taking away the schedule and the numbering system so you can submit posts directly to DD whenever you’d like. You can still submit images via email, but we’re going to increase the number of authors on the website and we’d like your help! Would you like to sign up? The only responsibility that you have is to post a Desmos image whenever you’d like. Yep that’s it! Interested? Comment on this post, contact me on twitter, or email me at my email address. Thanks!

Feedback On My Feedback System

In response to the Dark Lord Pershauron, I’ve decided to see what feedback you all have for my current SBG setup (v 5.0).
The course is Pre-Calculus honors. There are about 40ish standards for the year. About once a week students take a test on several standards (2-4). The first time they see the standard there is no grade; this is an opportunity for the students to see where they are. I started off giving them feedback but moved to self-feedback only: when finished, they go to a feedback station (@fnoschese style), grab a colored pen, look at the key and give themselves feedback. Sometimes they work in their groups to get the feedback and I put the key up on edmodo (all the keys end up on edmodo). They keep these feedback quizzes and put them in their folder.

The second time they see a standard it is for a grade, normally a week or two after we’ve taught the topic in class (grade out of 5: 5, 4.5, 4, 3, or 2). The grade goes in the books as is. They get three reassessment opportunities per term (out of 10-15 total standards per term). They see their graded quiz, but they don’t get to keep the graded assessment.
Things I need to get better at for next year:
Providing feedback myself to the student instead of just leaving it up to them. I like they they take responsibility in knowing what they know and don’t know, but I don’t think they are always able to give themselves the directed feedback that a teacher could give. I get a general idea of where the class is by informally going around and looking at quizzes post feedback, but I don’t have the whole picture. This informal feedback has changed the class, sometimes its obvious that they’ve understood a topic and we can move on, other times it’s clear that we need to take a different look at this material before moving on.

Thoughts? Comments? Let me have it. I see this as shot peening for my grading system. Thanks in advance!