aboutsummaryrefslogtreecommitdiff
path: root/rust/nth-prime/README.md
diff options
context:
space:
mode:
authorFederico Igne <git@federicoigne.com>2020-12-26 17:48:38 +0000
committerFederico Igne <git@federicoigne.com>2021-11-03 18:55:08 +0000
commit02481656966b0a8dfc95cf3c22bcc049660ff7d4 (patch)
tree8e39798fcaf27931d91c2088423fd4e97adcfc2d /rust/nth-prime/README.md
parent4e2052c4d792540c2f742b2c2a081b11117ed41d (diff)
downloadexercism-02481656966b0a8dfc95cf3c22bcc049660ff7d4.tar.gz
exercism-02481656966b0a8dfc95cf3c22bcc049660ff7d4.zip
Move Rust exercises in a subdirectory
Diffstat (limited to 'rust/nth-prime/README.md')
-rw-r--r--rust/nth-prime/README.md92
1 files changed, 92 insertions, 0 deletions
diff --git a/rust/nth-prime/README.md b/rust/nth-prime/README.md
new file mode 100644
index 0000000..425abde
--- /dev/null
+++ b/rust/nth-prime/README.md
@@ -0,0 +1,92 @@
1# Nth Prime
2
3Given a number n, determine what the nth prime is.
4
5By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that
6the 6th prime is 13.
7
8If your language provides methods in the standard library to deal with prime
9numbers, pretend they don't exist and implement them yourself.
10
11Remember that while people commonly count with 1-based indexing (i.e. "the 6th prime is 13"), many programming languages, including Rust, use 0-based indexing (i.e. `primes[5] == 13`). Use 0-based indexing for your implementation.
12
13
14## Rust Installation
15
16Refer to the [exercism help page][help-page] for Rust installation and learning
17resources.
18
19## Writing the Code
20
21Execute the tests with:
22
23```bash
24$ cargo test
25```
26
27All but the first test have been ignored. After you get the first test to
28pass, open the tests source file which is located in the `tests` directory
29and remove the `#[ignore]` flag from the next test and get the tests to pass
30again. Each separate test is a function with `#[test]` flag above it.
31Continue, until you pass every test.
32
33If you wish to run all ignored tests without editing the tests source file, use:
34
35```bash
36$ cargo test -- --ignored
37```
38
39To run a specific test, for example `some_test`, you can use:
40
41```bash
42$ cargo test some_test
43```
44
45If the specific test is ignored use:
46
47```bash
48$ cargo test some_test -- --ignored
49```
50
51To learn more about Rust tests refer to the [online test documentation][rust-tests]
52
53Make sure to read the [Modules][modules] chapter if you
54haven't already, it will help you with organizing your files.
55
56## Further improvements
57
58After you have solved the exercise, please consider using the additional utilities, described in the [installation guide](https://exercism.io/tracks/rust/installation), to further refine your final solution.
59
60To format your solution, inside the solution directory use
61
62```bash
63cargo fmt
64```
65
66To see, if your solution contains some common ineffective use cases, inside the solution directory use
67
68```bash
69cargo clippy --all-targets
70```
71
72## Submitting the solution
73
74Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer.
75
76## Feedback, Issues, Pull Requests
77
78The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
79
80If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
81
82[help-page]: https://exercism.io/tracks/rust/learning
83[modules]: https://doc.rust-lang.org/book/ch07-02-defining-modules-to-control-scope-and-privacy.html
84[cargo]: https://doc.rust-lang.org/book/ch14-00-more-about-cargo.html
85[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html
86
87## Source
88
89A variation on Problem 7 at Project Euler [http://projecteuler.net/problem=7](http://projecteuler.net/problem=7)
90
91## Submitting Incomplete Solutions
92It's possible to submit an incomplete solution so you can see how others have completed the exercise.