#include <cstdlib>
#include <iostream>
#include <conio.h>
#include<ctype.h>
#include<math.h>
using namespace std;
int main(int argc, char *argv[])
{
int isprime(int P);
for(int n=1; n<50;n++)
if (isprime(n)) cout<<n<<" ";
cout<<endl;
}
int isPrime(int p)
{
float sqrtp=sqrt(p);
if(p<2)return 0; //2 is
if(p==2)return 1;
if (p%2==0) return 0; // 2 is
for (int d=3;d<=sqrtp;d+=2)
if(p%d==0)return 0;
return 1;
system("PAUSE");
return EXIT_SUCCESS;
}
Tidak ada komentar:
Posting Komentar