Print Efficiency Prime Divisor



#include <bits/stdc++.h>
using namespace std;
void primefactor(int n)
{
 while(n%2==0)
 {
  cout << 2 << " ";
  n=n/2;
 }
 for(int i=3; i<=sqrt(n); i+=2)
 {
  while(n%i==0)
  {
   cout << i << " ";
   n=n/i;
  }
 }
 if(n>2){
    cout << n << endl;
 }
}
int main ()
{
 int n;
 cin >> n;
 primefactor(n);
 return 0;
}

Comments

Popular posts from this blog

কন্টেস্ট রিলেটড কিছু বিষয়

Efficiently getting all divisors of a given number

Print sum of prime divisor