Category Archives: Recursion

Image

Humanizing Factorials

Annos-Mysterious-Multiplying-Jar

With The Tower of Hanoi, I had fun with the evil powers of recursion. But I’m not actually learning code to teach my son to become a dictator, even a benevolent one, bearing brownies.   While we’re learning recursion, it’s probably not such a bad idea to bring up the some of the consequences of creating formulas that make work and data collection efficient, but potentially dehumanizing.

A few years back a friend gave Ben a lovely book that shows both ends of the spectrum of rich creativity and mechanistic abstraction. Anno’s Mysterious Multiplying Jar was written and illustraed in 1999 by the Japanese  father and son team, Mitsumasa and Masaichiro Anno.  It tells a simple story of factorial development that starts with a jar,  large enough to contain an ocean.

In this ocean is an island and on this island are two countries:

In each country are three mountains.  On each mountain, four walled kingdoms.  In each kingdom, five villages.  In each village, six houses.  In each house, seven rooms, in each room eight cupboards.  In each cupboard, nine boxes.  In each box, ten jars like the first.

The question at the end of the story is how many jars are contained inside the jar?   The answer is ,of course,  3,628,800  a.k.a.  10 factorial or !10.

The first part of the story is filled with richly illustrated picture of villages, houses, rooms, cupboards, all with their unique, individual characteristics.  The second part retells the story with dots instead.  It goes as far as a two page spread representing !8, or 40,320 dots.   The Annos don’t venture past that, since they’re writing a children’s book, not a heavy tome full of dots.

But the point, so to say, is made.

Advertisements

Tower of Hanoi

Subliminal hint, in German

An old school software engineer showed me a computational thinking exercise the other day that finally helped me understand recursion. Or at least brought me a step closer to figuring it out.

The Tower of Hanoi is a classic math puzzle.

Go work on it. I’m going to assume you’re smart enough to figure it out eventually. Come back when you’ve done that. And don’t come back until then.

**Hanoi tiger mom locks blog door**

Have you figured it out?  Oh really. So how many moves would it take to move a ten disk tower?  If you don’t know that, then you didn’t really figure it out! Get out of here!

**Locks door again (secretly bakes brownies)**

Figured it out?

Of course you did.  Have a brownie.

Now we can talk about your adventure. Remember that joyful moment of insight, when you realized that you could move a tower that reached the sky, if you wanted to, because you’d figured out the simple formula! (Start by moving the top 3 disks, then move the fourth disk on to the empty rod, then move the  3 disk tower back on top of the 4th disk, then move the 5th disk onto the empty rod, then move the 4 disk tower back on to that, then move the 6th disk onto the empty rod. Repeat forever.)  But then there was the  horrific realization of how much work that would involve, since every time you add a disk, the number of moves increases exponentially (the formula for figuring out the moves is actually (2 number of disks -1))

Welcome to a secret truth of civilization. Engineering has a simple solution to almost any problem, except where to find the slaves to actually do the totally tedious work!

A recursive formula is basically a formula that repeats the same work over and over, but always adding a little something else—or taking something away–so that the work is actually producing some kind of change.

Crack that and you’ve cracked a major concept in programming.

Now you just have to find slaves! Here bring them some brownies.