MCPcopy Create free account
hub / github.com/Hazrat-Ali9/Computer-Programming / is_prime

Method is_prime

Problem9.java:7–31  ·  view source on GitHub ↗
(int n)

Source from the content-addressed store, hash-verified

5public class Problem9 {
6
7 static int is_prime(int n) {
8 int i, root;
9
10 if (n < 2) {
11 return 0;
12 }
13
14 if (n == 2) {
15 return 1;
16 }
17
18 if (n % 2 == 0) {
19 return 0;
20 }
21
22 root = (int) Math.sqrt(n);
23
24 for (i = 3; i <= root; i += 2) {
25 if (n % i == 0) {
26 return 0;
27 }
28 }
29
30 return 1;
31 }
32
33 public static void main(String[] args) {
34 // TODO Auto-generated method stub

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected