Displays The Sequence of Primes
#include <iostream.h>
#include <conio.h>
void main(){
int input,arithmetic=0,i=1,b=2;
cout<<"input rate = ";cin>>input;
if (b==2)
{cout<<b<<" ";
b++;
i++;}
while (i<=input)
{
for (int z=2;z<b;z++)
{
if (b%z==0)
{arithmetic++;}
}
if (arithmetic==0)
{cout<<b<<" ";
i++;
b++;}
if (arithmetic>0)
{b++;
arithmetic=0;}
}
getch();
}
good luck with my friends :)
Tidak ada komentar:
Posting Komentar