Skip to content

Instantly share code, notes, and snippets.

@devmatheus
Created March 28, 2014 14:58
Show Gist options
  • Select an option

  • Save devmatheus/9834781 to your computer and use it in GitHub Desktop.

Select an option

Save devmatheus/9834781 to your computer and use it in GitHub Desktop.
Project Euler 01
<?php
/* Se listar todos os números naturais inferiores a 10 que são múltiplos de 3 ou 5, temos 3, 5, 6 e 9. A soma desses múltiplos é de 23.
* Encontre a soma de todos os múltiplos de 3 ou 5 abaixo de 1000.
*/
$soma = 0;
for ($i=1; $i<1000; $i++) {
$soma = (!($i%3) || !($i%5)) ? $soma+$i;
}
echo $soma;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment