task : debug the prime number logic
#include <stdio.h>
#include <math.h>
void main(){
int x,n=0,i;
scanf("%d",&x);
for(i=0;i<(int)sqrt(x);i++){
if(x%i==0){
n=1;
break;
}
}
if(n==1) printf("not");
else printf("PRIME");
}
#include <math.h>
void main(){
int x,n=0,i;
scanf("%d",&x);
for(i=0;i<(int)sqrt(x);i++){
if(x%i==0){
n=1;
break;
}
}
if(n==1) printf("not");
else printf("PRIME");
}
Comments
Post a Comment