© Ron Dai 2019
R. DaiLearn Java with Mathhttps://doi.org/10.1007/978-1-4842-5209-3_22

22. Factorization

Ron Dai1 
(1)
Seattle, WA, USA
 

In school math, we usually follow a procedure to find all factors for any given positive integer number. This process is called factorization, and it takes quite a lot of calculation depending on how big the integer number is. With the Java programming environment, let’s create a simple program to do the same job for us. We’d like to write code to find all factors of any positive integer. When a user inputs “10,” the program is supposed to output: 1, 2, 5, and 10. As the first step, we need to define the procedure and then implement it by Java code.

Math: Finding Factors

Recalling how we found factors manually in school, ...

Get Learn Java with Math: Using Fun Projects and Games now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.