Sunday, June 30, 2013

Euler question 1 in PHP

?php //this is a comment $ceiling = 1000; $total = 0; for ($tested_number = 1; $tested_number < 1000; ++$tested_number) { if($tested_number % 3 == 0) { $total += $tested_number; continue; } if($tested_number % 5 == 0) { $total += $tested_number; } } echo $total."
"; $total = 0; for ($tested_number = 1; $tested_number < 1000; ++$tested_number) { if($tested_number % 3 == 0 OR $tested_number % 5 == 0) { $total += $tested_number; } } echo $total."
" ?>