首页 > 编程语言 > 详细

[Introduction to programming in Java 笔记] 1.3.9 Factoring integers 素因子分解

时间:2016-02-20 00:28:05      阅读:306      评论:0      收藏:0      [点我收藏+]

素数 A prime is an integer greater than one whose only positive divisors are one and itself.
整数的素因子分解是乘积等于此素数的集合。
例如:3757208 = 2*2*2*7*13*13*397

public class Factors
{
    public static void main(String[] args)
    { // Print the prime factors of N. 
        long N = Long.parseLong(args[0]);
        long n = N;
        for (long i = 2; i <= n/i; i++)
        { // Cast out and print i factors
            while(n % i == 0)
            {
            n /= i;
            System.out.print(i + " ");
            // Any factors of n are greater than i.
            }
        } 
    if (n > 1) System.out.print(n);
    System.out.println();
    }
}

没看懂...









[Introduction to programming in Java 笔记] 1.3.9 Factoring integers 素因子分解

原文:http://www.cnblogs.com/learning-c/p/5202402.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!