Last active
August 29, 2015 14:06
-
-
Save montyanderson/daca7e9bba3a6250ffb8 to your computer and use it in GitHub Desktop.
Project Euler - Problem 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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