Adam Lesperance > Project-Euler > Project::Euler::Problem::P005

Download:
Project-Euler-0.20.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.20   Source  

NAME ^

Project::Euler::Problem::P005 - Solutions for problem 005 - Least common multiple

VERSION ^

version 0.20

HOMEPAGE ^

http://projecteuler.net/index.php?section=problems&id=5

SYNOPSIS ^

    use Project::Euler::Problem::P005;
    my $p5 = Project::Euler::Problem::P005->new;

    my $default_answer = $p5->solve;

DESCRIPTION ^

This module is used to solve problem #005

Use Math::BigInt to calculate the least common multiple between numbers

SETUP ^

Problem Number

    005

Problem Name

    Least common multiple

Problem Date

    30 November 2001

Problem Desc

2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?

Default Input

20

Default Answer

    232792560

Has Input?

    Yes

Help Message

The input controls the cap of the range of numbers to find the least common multiple of.

INTERNAL FUNCTIONS ^

Validate Input

The restrictions on custom_input

    A positve integer

Solving the problem

This is just goes from the largest multi_num until multiple_check returns true and returns that number.

This is like P3 in that it's definitely cheating and will have to be re-written with custom logic (even though it will almost certainly be much slower)

ACKNOWLEDGEMENTS ^

AUTHOR ^

Adam Lesperance <lespea@gmail.com>

COPYRIGHT AND LICENSE ^

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.

syntax highlighting: