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

h> void PrimeFactors (int n) { int count=0; int temp=0; for(int i=1;i<=n;i++) { int j=i-1; while(j>1) { if(i%j==0) break; else j--; } if(j==1) { if(n%i==0) { cout<<"\n"<<i; if(i>temp) { temp=i; count++; } } } } cout<<"\nNumber of prime factors of "<<n<<" : "<<count<<"\n"; cout<<"Greatest prime factor is "<<temp; } void main() { clrscr(); int n = 0; cout<<"***Welcome to Prime Factors program***\n"; cout<<"Enter the number : "; cin>>n; PrimeFactors(n); getch(); }

Sign up to vote on this title
UsefulNot useful