Project::Euler::Problem::P003 - Solutions for problem 003 - Max prime factor
use Project::Euler::Problem::P003; my $p3 = Project::Euler::Problem::P003->new; my $default_answer = $p3->solve;
This module is used to solve problem #003
Here we find the maximum prime factor of a given number. Math::Big::Factor is used to generate a prime wheel that finds all of the prime factors. From there it's a simple matter of taking the last one in the array to find the max value.
This will eventually be changed to use a custom-build prime generator to stay in the spirit of the Project Euler.
Max prime factor
02 November 2001
The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600,851,475,143?
There is little to no customization for this problem, simply tell it what you want to factor with custom_input
The restrictions on custom_input
A positive integer
Use factors_wheel to find all of the prime factors for the given number. Since the function always returns a sorted list, we can just return the last number in the returned array to find the max. In order to speed up the function whenever possible, a smaller wheel is generated if the number is less than 10 characters long
Adam Lesperance <firstname.lastname@example.org>
This software is copyright (c) 2010 by Adam Lesperance.