Sunday, 15 September 2013

PROGRAM TO FIND THE POSSIBLE PRIME FACTORS OF THE ENTERED NUMBER

/*MADE BY KRISHNA AGARWAL*/
#include<iostream>
using namespace std;
int main()
{
    int num,i,j=2,k;
    cout<<"enter the nubmer\n";
    cin>>num;
    cout<<"the result is \n";
    while(num>1)
    {
        if(num==0||num==1)
            cout<<"\nno possible prime factors for the entered number\n";
        else
        {
            if(num%j==0)
            {
                cout<<j<<"\n";
                num=num/j;
            }
            else
                j++;
        }
    }
}

PROGRAM TO PRINT THE SERIES OR THE PRIME NUMBERS

/*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;
}