<?php $answer = 2; $num1 = 1; $num2 = 2; $next = 0; while($next < 4000000) { $next = $num1 + $num2; if($next % 2 == 0) // 偶数の場合加算 { $answer += $next; } $num1 = $num2; $num2 = $next; } echo $answer; ?>