1
exercism fetch sml nth-prime

Nth Prime

Given a number n, determine what the nth prime is.

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.

If your language provides methods in the standard library to deal with prime numbers, pretend they don't exist and implement them yourself.

Hints

If the argument is not less than 1 raise the exception Domain.

Some of these concepts may be helpful:

Loading your exercise implementation in PolyML

1
$ poly --use {exercise}.sml

Or:

1
2
$ poly
> use "{exercise}.sml";

Note: You have to replace {exercise}.

Running the tests

1
$ poly -q --use test.sml

Feedback, Issues, Pull Requests

The exercism/sml repository on GitHub is the home for all of the Standard ML exercises.

If you have feedback about an exercise, or want to help implementing a new one, head over there and create an issue. We'll do our best to help you!

Source

A variation on Problem 7 at Project Euler http://projecteuler.net/problem=7

Submitting Incomplete Solutions

It's possible to submit an incomplete solution so you can see how others have completed the exercise.