/*MADE BY KRISHNA AGARWAL*/
#include<iostream>
using namespace std;
int main()
{
int terms,i,j=2,k,num;
cout<<"\nenter the number till which you want the prime numbers\n";
cin>>terms;
for(num=2;num<terms;num++)
{
j=2;
while(num>1)
{
if(num%j==0)
break;
else
j++;
}
if(j==num)
cout<<num<<" ";
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int terms,i,j=2,k,num;
cout<<"\nenter the number till which you want the prime numbers\n";
cin>>terms;
for(num=2;num<terms;num++)
{
j=2;
while(num>1)
{
if(num%j==0)
break;
else
j++;
}
if(j==num)
cout<<num<<" ";
}
return 0;
}
No comments:
Post a Comment