[Introduction to programming in Java notes] 1.3.9 factoring integers factor decomposition

Source: Internet
Author: User

Prime A Prime is an integer greater than one whose only positive divisors is one and itself.
The prime factor decomposition of an integer is a collection of the product equal to this prime number.
Example: 3757208 = 2*2*2*7*13*13*397

 Public classfactors{ Public Static voidMain (string[] args) {//Print The prime factors of N.        LongN = Long.parselong (args[0]); Longn =N;  for(Longi = 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 is greater than I.            }        }     if(N > 1) System.out.print (n);    System.out.println (); }}

Not understand ...









[Introduction to programming in Java notes] 1.3.9 factoring integers factor decomposition

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.