Skip to content

Instantly share code, notes, and snippets.

@montyanderson
Last active August 29, 2015 14:06
Show Gist options
  • Save montyanderson/daca7e9bba3a6250ffb8 to your computer and use it in GitHub Desktop.
Save montyanderson/daca7e9bba3a6250ffb8 to your computer and use it in GitHub Desktop.
Project Euler - Problem 1
<?php
$numbers = array();
/* Get all multiples of 3 and 5 */
for($i = 1; $i < 1000; $i++) {
if ($i % 3 == 0 || $i % 5 == 0) {
$numbers[] = $i;
}
}
/* Get the sum of them */
$output = 0;
foreach($numbers as $number) {
$output += $number;
}
echo $output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment