MIPI_BaseC_WebinarFRTK/06_Lecture06/12_prime_check_p30.c

25 lines
427 B
C
Raw Normal View History

2024-11-13 09:22:28 +03:00
#include <stdio.h>
int prime(int n)
{
//~ int i=2;
//~ while (i*i<=n)
for(int i=2;i*i<=n;i++)
{
if (n%i==0)
return 0;
//~ i++;
}
return 1;
}
int main()
{
int num;
scanf("%d",&num);
prime(num) ? printf("Prime") : printf("Not prime");
//printf("%s",prime(num) ? "Prime" : "Not prime");
//if (prime(num)) printf("Prime"); else printf("Not prime");
return 0;
}