public class rui{
static public void main(String[] args){
int temp;
boolean b = false;
for(int i=101;i<=300;i++){
temp = i;
b = false;
for(int j=2;j<i;j++){
while(temp%j ==0){
temp = temp/j;
if(!b){
System.out.print(i+"="+j);
b = true;
}
else
System.out.print("*"+j);
}
}
if(b)
System.out.println();
}
}
}
運行結果:
102=2*3*17
104=2*2*2*13
105=3*5*7
106=2*53
108=2*2*3*3*3
110=2*5*11
111=3*37
112=2*2*2*2*7
114=2*3*19
115=5*23
116=2*2*29
117=3*3*13
118=2*59
119=7*17
120=2*2*2*3*5
………………