Question about fading grid tutorial

Whats up guys, I’m working on that fading grid effect, and I’m stuck.

http://www.kirupa.com/developer/mx/fadegrid.htm

I have the effect completed, but using an arbitrary number that doesn’t produce an perfect grid.

In the tutorial he says that you have to find a number that is evenly divisble by the width and height of your pic…but the pics I’m using are already at a fixed size…and it’s tedious to use trial and error to try to find an exact number. I have an excel document with a trail and error based equation, but it’s not optimal, and I have yet to produce a perfect grid, although I’ve gotten close. Has anyone figured out how to get this magic number…is there an equation I’m missing?

thanks,
Ryan