Hi all.
I am trying to solve a problem from project euler, for the purpose of learning ? I’m not asking here for the answer or logic, I got the latter but it seems that I have a problem in outputting the integer since it exceeds the limit of variable limit in PHP (as I know).
[code=php]
<?php
$a = 0;
$b = 1;
$c = 0;
$even_count = 0;
for( $i = 0 ; $i < 4000000 ; $i++ ) {
$c = $a + $b;
$a = $b;
$b = $c;
if( $c % 2 == 0 ) {
$even_count += $c;
}
}
echo “Sum of all even-valued terms: ” . $even_count;
?>
The code is all about the sum of even numbers in the fibbonaci sequence which do not exceed four million.
Whenver I run the program the output as expected is
[CODE]Sum of all even-valued terms: INF
I can’t figure out how to output such big number. Any help? Thanks.