Go backward to Output Condition Go up to Top Go forward to Complete Specification |
Definition: p is the next such number after n.
Option 1: if n is prime, then isNextP(n, n).
isNextP(n, p) : <=> n <= p /\ ~(exists n <= q < p: isPrime(q)).
Option 2: even if n is prime, ~isNextP(n, n).
isNextP(n, p) : <=> n < p /\ ~(exists n < q < p: isPrime(q)).