I tried to sum up all even numbers from 0 to 200 and I found 2 possible working ways, however the third method (the most efficient one) gives me a headache. Here's what I did so far:
First method:
$total = 0;
$number = 0;
while ($number < 200)
{
if ($number % 2 == 0)
{
$total = $total + $number;
}
$number++;
}
echo $total;
Second method:
$total = 0;
for($number = 0; $number < 200; $number+=2)
{
$total += $number;
}
echo $total;
Third method (can't get it to work)
echo array_sum(range(1,200,2));
How should I change my last method so that it works as intended?
Edit: Seems that none of the methods work: the output should be 10100 but it is 9900 for the first two methods and 10000 for the third.