【华为机试】—— 6.质数因子

题目

解法

import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        long x = sc.nextLong();
        
        int base = 2;
        
        while(x>1){
            
            if(x % base == 0){
                System.out.print(base+" ");
                x /= base;
            }else {
                base++;
            }
            
        }
        
        sc.close();
    }

    
}

猜你喜欢

转载自www.cnblogs.com/bopo/p/9258899.html
今日推荐