// BILANGAN PRIMA
#include <iostream>
using namespace std;
void main()
{
int n, hitung=0, i=1, a=2;
cout<<"Enter the n value\t= ";
cin>>n;
if (a==2)
{
cout<<a<<"\n";
a++;
i++;
}
while (i<=n)
{
for (int x=2; x<a; x++)
{
if (a%x==0)
{hitung++;}
}
if (hitung==0)
{
cout<<a<<"\n";
i++;
a++;
}
else if (hitung>0)
{a++;
hitung=0;}
}
return;
}
Jumat, 23 November 2012
Program Mencari Bilangan Prima
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar
Budayakan Share ^_^