home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
InfoMagic Internet Tools 1995 April
/
Internet Tools.iso
/
infoserv
/
gopher
/
Unix
/
gopher-gateways
/
techinfo
/
techinpher
/
v1.0
/
isprime.c
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
C/C++ Source or Header
|
1993-01-14
|
421 b
|
25 lines
#include <stdio.h>
main()
{
char input[80];
int num, half;
int factor;
int prime;
while (fgets(input,sizeof(input)-1, stdin) != NULL) {
num = atoi (input);
do {
half = num/2;
for (prime=1, factor=2; factor < half && prime; factor++)
if ( num % factor == 0 ) prime = 0;
if (prime) {
printf ("%d is a prime number\n", num);
}
else {
num++;}
} while (!prime);
}
}