Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions PrimalityTest.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <stdio.h>
#include <math.h>
int main()
{
int T,N,a;
printf("Enter the no. of test cases\n");
scanf("%d",&T);//input the no. of test cases
for(int i=0;i<T;i++)
{
int k=0;
printf("Enter the no. you want to check whether it is prime or not\n");
scanf("%d",&N);//input the no. you want to check
if(N==1)
printf("no\n");
else
{
for(int j=2;j<=sqrt(N);j++)
{
a=N%j;
if(a==0)
{
k++;
break;//break is used to reduce time complexity
}
}
if(k>0)
printf("no\n");//it is not a prime no.
else
printf("yes\n");//it is a prime no.
}
}
return 0;
}
Binary file removed Screenshot.PNG
Binary file not shown.
Binary file added a
Binary file not shown.