Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Last active October 24, 2020 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbvf50mobile/795f4479249a6cc3b3f05c1d725afcc6 to your computer and use it in GitHub Desktop.
Save lbvf50mobile/795f4479249a6cc3b3f05c1d725afcc6 to your computer and use it in GitHub Desktop.
Just PHP FUN 137.
<?php
# https://www.codewars.com/kata/514b92a657cdc65150000006 Multiples of 3 or 5.
function solution($n){
$sum = 0;
for($i = 3; $i < $n; $i += 3) if(0 != $i%5) $sum += $i;
for($i = 5; $i < $n; $i +=5) if(0 != $i%3) $sum += $i;
for($i = 15; $i < $n; $i += 15) $sum += $i;
return $sum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment