Monday, February 01, 2010

Project Euler Problem 1

Project Euler Problem 1: Add all the natural numbers below one thousand that are multiples of 3 or 5.

<?php

$s = 0;
for ($i = 3; $i < 1000; $i++)
if (!($i%3) || !($i%5)) $s += $i;
echo $s;

?>

0 Comments...

Post a Comment

 · Blog Index