The smallest factor of x could be 2.
So, the largest factor is at most x/2.
There's a good chance that there's a prime between x/2 and x. So, start working backwards from x and checking the numbers for primality.
how would you calculate the largest prime number given a number x so for example say someone inputs 8 , the largest prime number is 7.
1 answer