After defining anyFactor, define isPrime as by saying that n is prime is it does not have any factor from 2 to n-1. Add an Execute part that does some tests of isPrime.
Hint.
anyFactor(n,i,j) is always false when i > j, because then there are no numbers k at all that satisfy i < k ≤ j, let alone any that are factors of n.
Otherwise, if i is a factor of n, then there certainly is a factor of n in that range.
What should you do in the case where i ≤ j and i is not a factor of n?