C
c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
/* uses int for BOOLEAN
Since int is the fastest data type in C
and FALSE & TRUE are defined with macro
#define, it is the fastest implementation
of BOOLEAN.
*/
typedef int BOOLEAN;
#define TRUE (1)
#define FALSE (0)
int main(){
int n,i;
// Enter a number:
scanf("%d",&n);
BOOLEAN flag=TRUE;
for( i=2;i*i<=n;++i ){
if( n%i==0 ){
flag=FALSE;
break;
}
}
if( flag ) printf(" %d is a prime number\n",n);
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run