Prime Factorization
This JavaScript program calculates the prime factorization of the given integer.
The program
Instructions
Enter the number to be factored in the input text field, then click the Factor
button. The number must be between 2 and 9 007 199 254 740 992 (253), inclusive.
Examples:
- 28663 = 28663 (prime)
- 79068 = 2 × 2 × 3 × 11 × 599
- 4631109768372803 = 103 × 44962230760901 (after a short delay)
- 9007199254740881 = 9007199254740881 (the largest prime number within range)
Warning: If the number is a large prime or contains large prime factors, the program will hang. This is because the worst-case running time is proportional to the square root of the input number (O(√n)). Although most browsers allow the user to stop scripts that run for excessively long, you should not assume this; be prepared to forcibly terminate the browser program.
Links
Last modified: 2008-04-16-Wed
Created: 2007-08-16-Thu