A prime number is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime because the only ways of writing it as a product, 1 × 5 or 5 × 1, involve 5 itself.

PRIME NUMBER

#include<iostream>

using namespace std;

int main()

{

int num,n,i;

cout<<"Enter the upper limit:";

cin>>n;

cout<<"\n PRIME NUMBERS:";

for(num=1;num<n;num++)

{

for(i=2;i<num;i++)

{

if(num%i==0)

break;

}

if(num==i)

cout<<"\t"<<num;

}

return 0;

}


OUTPUT:




BY:
      REGU RAM SV.

Post a Comment

أحدث أقدم