#include <iostream>
#include<math.h>
using namespace std;
bool prima (int x){
int k,y;
bool test;
if(x<2){
return false;
}else if (x==2){
return true;
}else {
y = ceil(sqrt(x));
test= true;
}
while (test && (y>=2)){
if (x % y ==0){
test=false;
}else {
}
}
return test;
}
int main(int argc, char *argv[])
{
int x;
cout<<"masukkan nilai:"<<endl;
cin>>x;
cout<<"prima:"<<prima(x)<<
system("PAUSE");
return EXIT_SUCCESS;
}
No comments:
Post a Comment