Well, you could brute force it and check to see if a particular number is divisible by all the numbers up until that number. However, there are some tricks that allow one to skip a lot of numbers. First, if a number is even it is not prime, so you only need to check odd numbers. Also, you only need to check if a number is divisible by primes, so if you keep a list that will help. There are probably more shortcuts than that.