We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 5c05334 + c837326 commit e9dc251Copy full SHA for e9dc251
prime_number/prime_number.c
@@ -0,0 +1,26 @@
1
+#include <stdio.h>
2
+#include <stdlib.h>
3
+#include <math.h>
4
+
5
+bool prime(long long n) {
6
+ if (n < 2) return false;
7
+ if (n == 2) return true;
8
+ if (n % 2 == 0) return false;
9
+ for (int i = 3; i <= sqrt(n); ++i) {
10
+ if (n % i == 0) return false;
11
+ }
12
+ return true;
13
+}
14
15
+int main(int argc, char const *argv[]) {
16
+ long long n;
17
+ bool aux;
18
+ scanf("%lld", &n);
19
+ aux = prime(n);
20
+ if (aux == true) {
21
+ printf("it's prime!\n");
22
23
+ else
24
+ printf("it's not prime!\n");
25
+ return 0;
26
0 commit comments