Project::Euler::Problem::P002 - Solutions for problem 002 - Sum filtered fib numbers
version 0.20
http://projecteuler.net/index.php?section=problems&id=2
use Project::Euler::Problem::P002; my $p2 = Project::Euler::Problem::P002->new; my $default_answer = $p2->solve;
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)
An array of positive numbers that are used to filter out the fib numbers
002
Sum filtered fib numbers
2001-10-19
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.
4,000,000
4,613,732
Yes
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!
The restrictions on custom_input
A positive integer
Generate all of the fib numbers up to $max, filtering them by the multi_nums attribute, and find the sum
Adam Lesperance <lespea@gmail.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.