Smallest Common Multiple - Unwanted oscillating result from while loop

I struggled a bit on this one to start - mostly because it was a surprisingly deep challenge that more resembled a project. However I sketched abrute force solution in a post yesterday:

Are you familiar with:

  • Sieve of Eratosthenes for finding prime numbers?

  • Are you familiar with prime factorization?

  • Do you realize that the *prime factorization of each number is unique?

Hopefully these hints at the math behind this problem, and solution, help out.