Factorization: Some Drawings

So here’s the very high level flowchart for the factorization program. The key insight here is that the things the program does are grouped together and put inside pretty inclusive boxes. The lower-level flowcharts will start to unpack these boxes. The really interesting thing about this is that for any box we don’t really know how to implement, we can just put in a stub that pretends to do the work. Like, “Oh, I don’t know how to do prime factorization so I’m just going to print the number 5 and move on.” Computer programming is all like this: break the problem down into smaller and smaller chunks until each chunk is something you know how to tell a computer to do.

Okay, now I’ve got a choice; which box do I go into first? Given that I’ve gotta do all of them, I could do the most interesting one first (or last), or start with the easiest (or hardest). Ultimately, it’s down to what I feel like. Okay. I hate doing validation of user-input data (it’s not a secret: nobody likes doing validation of user-input data). I’m going to save that bit for the end. Hooray! Let’s do the factorization chunk, because that’s interesting and it’s got some math in it.

Notice that although a lot of these steps are pretty easily translated directly into lines of BASIC, there’s still a box for “get the next prime number.” It’s getting late and I’ve got other stuff to do, so that’s it for today. I guess I’ll have to cover generating primes and keeping track of where we are in the list of primes next time around.

Published by pirateguillermo

I play the bagpipes. I program computers. I support my family in their various endeavors, and I enjoy my wonderful life.

One thought on “Factorization: Some Drawings

Leave a Reply