CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of euler
# 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.
 
$target = 999
 
#first solution (easy)
$vals=1..$target
$ansA = 0
foreach($v in $vals) { 
    if($v % 3 -eq 0 -or $v % 5 -eq 0) {
by Please enter a name...   September 04, 2009 @ 7:02pm
231 Views
no comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate