up previous next
find smallest prime which does not divide an integer
SmallestNonDivisor(N: INT): INT |
This function finds the smallest prime which does not divide an integer.
It simply tries dividing by all primes in increasing order until it finds
one which does not divide
N
.
/**/ SmallestNonDivisor(factorial(100));
101
/**/ SmallestNonDivisor(-100);
3
|