描述
输入n,把n分解成质因数的乘积。
输入
输入整数n(n>=2)
输出
n分解成质因数的乘积
样例输入
50
样例输出
50=2*5*5
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
using namespace std;
bool zhishu(int &n)
{
for(int i=2;i*i<=n;i++)
if (n%i==0)
{
cout<<i<<"*";
n /= i;
return true;
}
return false;
}
int main()
{
int n;
cin>>n;
cout<<n<<"=";
for(;zhishu(n););
cout<<n<<endl;
system("pause");
return 0;
}