math - Project Euler Spoilers, #001 - PHP Sums -



math - Project Euler Spoilers, #001 - PHP Sums -

i cannot inquire help on forums, i've been @ 3 hours now. spoilers below don't understand i'm doing wrong. question is:

if list natural numbers below 10 multiples of 3 or 5, 3, 5, 6 , 9. sum of these multiples 23. find sum of multiples of 3 or 5 below 1000.

here's equation made.

for($total = 0, $f = 5, $t = 3; $t < 1000; $t+=3){

if($f < 1000) { $total += $f + $t; echo "five: $f, three: $t = $total"; $f += 5; } else { $total += $t; echo "five: $f, three: $t = $total"; } }

the reply is:233168. where's error?

you counting numbers divisible both 3 , 5 twice.

php math

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -