This article introduces Java code analysis of prime factors of number decomposition
import java.util.Scanner; /** * Created by Admin on 2017/3/18. */ public class Test01 { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int i,n; n=scan.nextInt(); System.out.print(n+"="); for (i=2;i<=n;i++){ while (n!=i){ if(n%i==0) { n = n / i; System.out.print(i+"*"); } else break;; } } System.out.println(n); } }
The above is the detailed content of Java code analysis of prime factors of a number decomposition. For more information, please follow other related articles on the PHP Chinese website!