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 1de234e + b085185 commit 0880315Copy full SHA for 0880315
PrimalityTest.c
@@ -0,0 +1,33 @@
1
+#include <stdio.h>
2
+#include <math.h>
3
+int main()
4
+{
5
+ int T,N,a;
6
+ printf("Enter the no. of test cases\n");
7
+ scanf("%d",&T);//input the no. of test cases
8
+ for(int i=0;i<T;i++)
9
+ {
10
+ int k=0;
11
+ printf("Enter the no. you want to check whether it is prime or not\n");
12
+ scanf("%d",&N);//input the no. you want to check
13
+ if(N==1)
14
+ printf("no\n");
15
+ else
16
17
+ for(int j=2;j<=sqrt(N);j++)
18
19
+ a=N%j;
20
+ if(a==0)
21
22
+ k++;
23
+ break;//break is used to reduce time complexity
24
+ }
25
26
+ if(k>0)
27
+ printf("no\n");//it is not a prime no.
28
29
+ printf("yes\n");//it is a prime no.
30
31
32
+ return 0;
33
+}
Screenshot.PNG
-204 KB
a
8.26 KB
0 commit comments