Prime Factor code in JavaScript
We'll go about the code in a simple way:
Step 1:
Starting with 2, find the first factor of the number of interest
- this factor will definitely be a prime.
Store this factor away.
Step 2:
Divide number in question by found factor.
Step 3:
Using result from Step 2 as the new number
in question (number whose prime factors we are trying to find),
repeat Step 1.
Step 4:
Continue recursively until we arrive at 1.
Step 5:
We'll use the square-root of number range.
Create a new file; On Notepad++: File, New.
Call it PrimeFactors.html.
Type out the adjoining JavaScript code for listing prime factors.