Skip to content

Commit 1fb264f

Browse files
committed
iluwatar#6 Update readme
1 parent 871838a commit 1fb264f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Update the sample application with the snippet and add a test for it. After prov
2828
* [Factorial](#factorial)
2929
* [Fibonacci](#fibonacci)
3030
* [Lottery](#lottery)
31+
* [Prime](#prime)
3132

3233
### Media
3334
* [Capture screen](#capture-screen)
@@ -251,6 +252,29 @@ Update the sample application with the snippet and add a test for it. After prov
251252

252253
[⬆ back to top](#table-of-contents)
253254

255+
### Prime
256+
257+
```java
258+
public static boolean isPrime(int number) {
259+
if (number < 3) {
260+
return true;
261+
}
262+
// check if n is a multiple of 2
263+
if (number % 2 == 0) {
264+
return false;
265+
}
266+
// if not, then just check the odds
267+
for (int i = 3; i * i <= number; i += 2) {
268+
if (number % i == 0) {
269+
return false;
270+
}
271+
}
272+
return true;
273+
}
274+
```
275+
276+
[⬆ back to top](#table-of-contents)
277+
254278
## Media
255279

256280
### Capture screen

0 commit comments

Comments
 (0)