Sometimes the cog will go a great many times around the wheel before the pattern joins up. For example, if the wheel has a 150 teeth and the cog has 61 then the cog will go 61 times around
The code is Pattern9.java.
Flower Patterns
SpiroGraphics
Try it out for yourself