问题描述
求出区间[a,b]中所有整数的质因数分解。
输入格式
输入两个整数a,b。
输出格式
每行输出一个数的分解,形如k=a1a2a3…(a1<=a2<=a3…,k也是从小到大的)(具体可看样例)
样例输入
3 10
样例输出
3=3
4=22
5=5
6=23
7=7
8=222
9=33
10=25
提交代码
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,i,j ;
cin>>a>>b;
for( i = a;i <= b;i++){
int n = i;
j = 2;
cout<<i<<'=';
while (n!=j){
for(j = 2;j <n;j++)
{
if(n%j==0 && n != j){
cout<<j<<'*';
n /=j;
break;
}
}
}
cout<<n<<endl;
}
return 0;
}