Solution for rotation of a system of wheels and breaking them into prime factors. I found an interesting puzzle and the solution that involves primes. 
Problem
The BrainBashers mechanical computer is a very sensitive device, in consists of four sequential cog wheels which are in constant mesh.
The largest cog has 63 teeth and the others have 42, 35 and 27 respectively.
By accident, Daniel started to rotate the largest cog.
How many revolutions must he rotate the largest cog make before the computer is back in its starting position with all of the cogs where they started?
Solution
If we break each wheel into its prime factors, we get:
63 = 3 x 3 x 7
42 = 2 x 3 x 7
35 = 5 x 7
27 = 3 x 3 x 3
We now think of rotating the large wheel just once, and this is 3 x 3 x 7 teeth moved (3 x 21), and we can see that 42 tooth wheel also has a 3 x 7 (21 teeth) in it, with an extra 2. If we therefore rotate the 63 toothed wheel twice, the 42 will have rotated three times.
The answer involves cancelling any common factors from the large wheel. We can cancel 3, 3, 7 from any of the smaller ones to leave 2 (from the 42), 5 (from the 35) and 3 (from the 27). 2 x 5 x 3 = 30. QED.

How were they able to understand that by rotating 63 toothed wheel twice, the 42 will have rotated three times?
My way of thinking was that they have to cover the same distance by rotating. I don't think it is correct.
WHY is it ok to cancel any common factors from the large wheel and HOW did they do it? As I understand when you cancel we cancel 3 and 7 from 63 and 42 for example. So, we get: 
63 = 3
42 = 2
Then we cancel 3 from 63 and 3 from 27 and we get. As the result we have 3x5x7x3x3 = 945
63 = 
42 = 2
35 = 5 x 7
27 = 3 x 3
Thank you.
Original problem: Puzzle #11
 A: To go directly to the answer, you take the least common multiple of your numbers $63$, $42$, $35$, and $27$, which is $1890$, then divide by your biggest number $63$ to get $30$ turns of that biggest gear. Now let me make the answer clear:
For myself, it makes things clearer to straighten out the toothed circumferences to four measuring sticks of length $63$, $42$, $35$, and $27$ centimeters, respectively. You lay them out repeatedly on four parallel lines, the $63$-cm stick on the top line, the $42$-cm stick on the second, etc. You’ve already noticed that laying down the first one twice gets you to the same point as laying down the second one three times, both to measure $126$ cm. That $126$ is a common multiple of $63$ and $42$, and you quickly see that if you were putting a tick mark on each of the lines at each point where the end of the stick came down, then you’ll get all four tick marks lining up at any time when the distance along the line is a common multiple of your four stick-lengths. The common multiples of those four numbers are $0$, $1890$, $2\times1890=3780$, etc. And how many times had you laid down the $63$-cm stick to get to the $1890$-cm distance? Well, $1890/63=30$ times.
Only remains to say how I got that $1890$. If you write $63=2^03^25^07^1$, $42=2^13^15^07^1$, $35=2^03^05^17^1$, and $27=2^03^35^07^0$, you just use the maximum of the exponents on each of the primes, to get $2^13^35^17^1=1890$.
