java之将101-300范围内整数分解为质因数

来源:互联网 发布:移动是什么网络模式 编辑:程序博客网 时间:2024/06/14 07:26
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;}elseSystem.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
………………

0 0
原创粉丝点击