Example of prime factor algorithm for decomposing arbitrary input numbers in Java

This paper describes the prime factor algorithm for decomposing arbitrary input numbers in Java. Share with you for your reference, as follows:

Decompose the prime factor of any input number:

Concept of prime factor: any composite number can be written in the form of multiplication of several prime numbers. Each prime number is a factor of the composite number, which is called the decomposition prime factor of the composite number. The decomposition prime factor is only for composite numbers.

For example: 12 = 2x2x3, 18 = 2 x 3 x 3, etc

Let's explain the idea of this algorithm: first, we first write a function for finding prime numbers; Second; We make a function to decompose the prime factor, and then introduce the prime function to judge whether it is prime or not;

Codes are given below (for reference only):

Operation results:

PS: Here we recommend several calculation tools for your further reference:

Online decomposition quality factor calculator tool: http://tools.jb51.net/jisuanqi/factor_calc

Online univariate function (equation) solving calculation tool: http://tools.jb51.net/jisuanqi/equ_jisuanqi

Scientific calculator Online_ Advanced calculator online computing: http://tools.jb51.net/jisuanqi/jsqkexue

Online calculator_ Standard calculator: http://tools.jb51.net/jisuanqi/jsq

For more information about Java algorithms, readers who are interested can see the topics on this site: Java data structure and algorithm tutorial, summary of Java DOM node operation skills, summary of java file and directory operation skills, and summary of Java cache operation skills

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>