题目 1563: 蓝桥杯-质因数
题目描述:
将一个正整数N(1< N< 32768)分解质因数。例如,输入90,打印出90=2*3*3*5。
代码:
package lanqiao;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int b = 1;
System.out.print(n + "=");
while(n != 1)
{
b ++;
if(n % b == 0){
n = n/b;
if(n == 1){
System.out.print(b);
}
else{
System.out.print(b + "*");
b = 1;
}
}
}
}
}
原文地址:https://blog.csdn.net/weixin_64443786/article/details/136509793
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!