Essentially you want to know what the least common multiple of their respective rate times...
18=2*3*3 and 45=3*3*5 so the least common multiple is 2*3*3*5=90
check
90/45=2 rev
90/18=5 rev
Notice that these are complete revolutions which is what we want, complete revolutions at the same time...