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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Introduction to programming in Java 笔记] 1.3.9 Factoring integers 素因子分解相关的知识,希望对你有一定的参考价值。

素数 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 素因子分解的主要内容,如果未能解决你的问题,请参考以下文章

[转帖]Programmer’s guide to the big tech companies 💻

Analysis of algorithms: introduction

To Be A Good Programmer? All it takes is these 10 habits !

To Be A Good Programmer? All it takes is these 10 habits !

why does it suck to be an in-house programmer?

Introduction to Unity UI