JavaScript Implementation of Problem 3

View source code here on GitHub!

Includes

Problem Solution

p0003()

Project Euler Problem 3

Finally ported prime factor generator to js

Problem:

The prime factors of 13195 are 5, 7, 13 and 29.

What is the largest prime factor of the number 600851475143 ?

Returns:

number --

 1/**
 2 * Project Euler Problem 3
 3 *
 4 * Finally ported prime factor generator to js
 5 *
 6 * Problem:
 7 *
 8 * The prime factors of 13195 are 5, 7, 13 and 29.
 9 *
10 * What is the largest prime factor of the number 600851475143 ?
11 *
12 * @return {number}
13 */
14exports.p0003 = function() {
15    return Math.max(...primes.primeFactors(600851475143));
16};
17
18const primes = require('./lib/primes.js');

Tags: factorization, prime-number, js-iterator