Saturday, December 20, 2014

The Twelve Days of Christmas (Reprise)

(Click on the comic if you can't see the full image.)
(C)Copyright 2014, C. Burke.

Expressing my True Love mathematically and recursively.

This comic calls to mind my Twelve Triangle Numbers of Christmas from way back in 2007.

Once again, I used pseudo-code here, and not any particular programming language. I wouldn't program it exactly like this, but I wanted it to be readable.

As for the summations, those actually caused me some problems -- or at least a bit of thought about how they work, which is something I'll have to refresh my memory on. However, the one thing that occured to me is that I wanted the gifts in order, not just an actual sum of the number of gifts, and I wanted it to match the code. That meant that I had to count backward (or count down). Unfortunately, summations (to my knowledge at this point) count up. That meant minus signs and +1s, which I eliminated by starting j at 0 instead of 1.

More on this tomorrow, probably.




2 comments:

  1. I'll grant the summation is not recursive (just mathematical), and I've never heard the term used that way.

    But the GIVE routine calls itself with Yesterday's number, all the way down to 1.

    ReplyDelete
  2. my mistake, it's iterative on the outer loop but recursive on the fast wheel of the odometer

    ReplyDelete