Skip to content

Instantly share code, notes, and snippets.

@pmgupte
Last active December 22, 2015 03:19
Show Gist options
  • Save pmgupte/6409805 to your computer and use it in GitHub Desktop.
Save pmgupte/6409805 to your computer and use it in GitHub Desktop.
My PHP solution to Project Euler problem # 1 http://projecteuler.net/problem=1 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.
<?php
$sum = 0;
for ($i = 0; $i < 1000; $i++) {
if (!($i % 3) || !($i % 5)) {
$sum += $i;
}
}
echo $sum;
?>
@pmgupte
Copy link
Author

pmgupte commented Sep 2, 2013

code in revision 9a8e4d24c7a9df5cbd8f6b7794fd521f55269585 took 0.0017611980438232 seconds to finish.
whereas, code in revision de495615e1f9741a39e00bf4ee5cc88d6360c880 took only 0.00026798248291016 to finish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment