NAME
Project::Euler::Problem::P002 - Solutions for problem 002 - Sum filtered fib numbers
VERSION
version 0.20
HOMEPAGE
http://projecteuler.net/index.php?section=problems&id=2
SYNOPSIS
use Project::Euler::Problem::P002;
my $p2 = Project::Euler::Problem::P002->new;
my $default_answer = $p2->solve;
DESCRIPTION
This module is used to solve problem #002
This is a simple problem which computes the fib numbers up to a certain maximum and sums all of them that are even (or as implemented here, divisible by every integer in multi_nums)
ATTRIBUTES
multi_nums
An array of positive numbers that are used to filter out the fib numbers
- Isa
-
PosIntArray
- Default
-
[2]
SETUP
Problem Number
002
Problem Name
Sum filtered fib numbers
Problem Date
2001-10-19
Problem Desc
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
Find the sum of all the even-valued terms in the sequence which do not exceed four million.
Default Input
Default Answer
4,613,732
Has Input?
Yes
Help Message
You can change multi_nums
to alter the way the program will function. If you are providing custom_input, don't forget to specify the wanted_answer if you know it!
INTERNAL FUNCTIONS
Validate Input
The restrictions on custom_input
A positive integer
Solving the problem
Generate all of the fib numbers up to $max, filtering them by the multi_nums attribute, and find the sum
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.