You are viewing a single comment's thread. Return to all comments →
PHP
<?php function dmss($max) { $i = 0; $num = 2; $first_num = 1; $second_num = 2; while ($num <= $max) { if ($num%2 == 0) { $i = $i+$num; } $num = $first_num + $second_num; $first_num = $second_num; $second_num = $num; } return $i; } $handle = fopen ("php://stdin","r"); fscanf($handle,"%d",$t); for($a0 = 0; $a0 < $t; $a0++){ fscanf($handle,"%ld",$n); $i = dmss($n); echo $i."\r\n"; } ?>
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #2: Even Fibonacci numbers
You are viewing a single comment's thread. Return to all comments →
PHP