Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // My answer to http://projecteuler.net/problem=2
- $tot = 0;
- $nums = array(1);
- $a = 0;
- while ($a < 4000000) {
- $a = array_sum($nums);
- if ($a%2==0) {
- $tot += $a;
- }
- array_push($nums,$a);
- if (count($nums)>2) {
- array_shift($nums);
- }
- }
- echo $tot;
- exit;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment