Project::Euler::Problem::P004 - Solutions for problem 004 - Largest palindrome from prods
use Project::Euler::Problem::P004; my $p4 = Project::Euler::Problem::P004->new; my $default_answer = $p4->solve;
This module is used to solve problem #004
Given the length of ints to iterate through, we will find the largest product that produces a palindrome.
Largest palindrome from prods
16 November 2001
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 & 99. Find the largest palindrome made from the product of two 3-digit numbers.
The number of digits the numbers should have
There is little to no customization for this problem, simply tell it what you want the number of digits to be
The restrictions on custom_input
A positive integer
First we will calculate the int that we will be using to loop on. Then we will iterate backwards from that number to the smallest int the same number of digits (ie 999 down to 100). The inner loop will always start with the current outer loop so no duplicate products are tested.
If we ever iterate the outer loop down and that number squared is less than the max number found, then we will stop since it is impossible for any larger number to ever be generated.
Adam Lesperance <email@example.com>
This software is copyright (c) 2010 by Adam Lesperance.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.