User:Mido1236/It's All About Three

Try to divide the input number n by all numbers from 2 till 1000, the square root of 1 million, which is the input limit. For each valid divisor you find, keep dividing n by it as much as you can (i.e.: until the remainder is no longer zero). If before n becomes 1 due to the divisions, a number whose last digit is not 3 divides it with no remainder, then return false. If after successfully trying all numbers n is one or the last digit of n is 3 return true; otherwise, return false. Just make sure to handle the cases for n<3. It's possible to do an erastothenes sieve to find all prime numbers from 2 to 1000 rather than trying them all.