Followers

Saturday, December 3, 2011

PRIME FACTORISATION

#include<iostream.h>
#include<conio.h>

void main()
{
 clrscr();
 int n, x, m;
 cout<<"Enter any number : ";
 cin>>n;
 cout<<"Prime factors : \n";
 m=n;
 for(int i=2; i<=n/2;)
  {

   x=m%i;
   if(x==0)
    {
     cout<<i<<"\n";
     m=m/i;
    }
   else
    i=++i;
  }
 getch();
}
.................................................................
OUTPUT:(click on image to enlarge)

No comments:

Post a Comment