Scheme Exercises

back to exercise list       previous     next

Group:     Exercise: 33/48 

NextPrime:  Find the next prime at or after a given number

Create the function NextPrime which will be given a positive integer (greater than 1) and will return that number if it's prime, otherwise it will return the next number larger than that, that is prime.
For instance:
(NextPrime 7) ; -> 7
(NextPrime 8) ; -> 11
(NextPrime 48) ; -> 53