JAVA变成把一个整数分解成多个质数的积
/* * TestTengXun.java * Version 1.0.0 * Created on 2017年12月2日 * Copyright ReYo.Cn */ package reyo.sdk.utils.test.w; import java.util.Scanner; public class Testzhi { @SuppressWarnings("resource") public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("输入一个数:"); long number = in.nextLong(); System.out.print(number + "="); int i = 1; while (i < number) { if (number % i == 0 && i == 1) { System.out.print(i + "x"); number /= i; } else if (number % i == 0 && i != 1) { System.out.print(i + "x"); number /= i; continue; } i++; } System.out.print(i); } }