Java Implementation of Problem 3

View source code here on GitHub!

Includes

Problem Solution

public class p0003 implements IEuler
Object answer()
Returns:

The answer to Project Euler problem 3

 1/*
 2Project Euler Problem 3
 3
 4The lesson I've taken from these is that Streams are significantly more cumbersome in Java than in other languages
 5
 6Problem:
 7
 8The prime factors of 13195 are 5, 7, 13 and 29.
 9
10What is the largest prime factor of the number 600851475143 ?
11*/
12package euler;
13
14import java.util.Comparator;
15
16import euler.lib.Primes;
17
18public class p0003 implements IEuler {
19    @Override
20    public Object answer() {
21        return Primes.primeFactors(600851475143L)
22                     .max(Comparator.naturalOrder())
23                     .get()
24                     .shortValue();
25    }
26}

Tags: factorization, prime-number, java-iterator