#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define TRUE 1
#define FALSE 0	
	       
typedef long Yesno;
Yesno is_prime(long n);
/* check for prime function prototype */

int main()
{ unsigned long p; char ch; while(1) { srand((unsigned)time(NULL)); for(;;) { p = rand(); if (is_prime(p)) break; } printf("%u is prime.\n", p); puts("Do you want another one? (y or n)?"); do { ch = getchar(); } while(ch != 'n' && ch != 'y'); if(ch == 'n') break; } system("PAUSE"); return 0; } Yesno is_prime(long n) { long divisor; if (n<=1) return FALSE; for (divisor = 2; divisor * divisor <= n; divisor++) if (n % divisor == 0) return FALSE; return TRUE; }

:: Top ::

code dog Tucker
E2 logo
End Poverty
Debt AIDS Trade Africa
World Community Grid
Valid XHTML 1.0 Transitional