Monday, July 4, 2016

Finding the LCM with Python

Middle school students first learn to find LCM by listing multiples, then they learn to do it by factoring.

I started playing around on Python creating, what I thought would be, a really simple program to find LCM by listing and comparing multiples.  The goal would be to help students understand what LCM means before moving on to simpler ways to find LCM.

My method turned out to be REALLY convoluted and messy.  I just sat down and started typing and did absolutely no planning.

I ended up using TEN variables just to compare two sets of multiples.  It's a good lesson in balancing the "never give up until the problem is solved" mentality to the "quit and find a better way to do it" mentality. In this case, I should have quit, gotten out a sheet of paper, and outlined a better way to do it.

Incidentally....there is no LCM function in Python.  The simplest algorithm I've seen is the one linked above.

No comments:

Post a Comment