Jan-19-2018, 10:21 PM
The reason you are being asked to do such a large number is specifically because brute force methods like this won't work. You are required to come up with a more efficient method.
One relatively efficient method would be to find all possible prime factors that are less than or equal to the square root of the number. Then check only those numbers.
First look up how to write a prime sieve (Eratosthenes will work). Then for each number in the sieve check if it is a factor and divide the number if so.
One relatively efficient method would be to find all possible prime factors that are less than or equal to the square root of the number. Then check only those numbers.
First look up how to write a prime sieve (Eratosthenes will work). Then for each number in the sieve check if it is a factor and divide the number if so.