Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1fb264f

Browse files
committed
iluwatar#6 Update readme
1 parent871838a commit1fb264f

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+
publicstaticboolean isPrime(int number) {
259+
if (number<3) {
260+
returntrue;
261+
}
262+
// check if n is a multiple of 2
263+
if (number%2==0) {
264+
returnfalse;
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+
returnfalse;
270+
}
271+
}
272+
returntrue;
273+
}
274+
```
275+
276+
[⬆ back to top](#table-of-contents)
277+
254278
##Media
255279

256280
###Capture screen

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp