# How to find the sum of all the multiples of 3 or 5 below 1000 through PHP

1k views
in PHP

by (9.9k points)
selected

Solution: To find the multiple of 3 or 5 simply write and run the following code

let variables be  $sum = 0,$n

<?php
$sum = 0; for ($n = 0; $n < 1000;$n++)
{
if (!($n % 5) || !($n % 3))
{
$sum +=$n;
}
}
echo \$sum;

?>