Php taking more than 30 sec : Error!
Posted: Mon Oct 26, 2009 10:38 am
Sum of squares of all even numbers of the array + Square of sum of all odd number in the numbers array:
It could not understand where is the error :(
If you have different approach please let me know..
please help.....
It could not understand where is the error :(
If you have different approach please let me know..
Code: Select all
<?
$numbers="2 51 12 32 10 5 88 3";
$number=explode(" ",$numbers);
for($i=0; $number[$i]!='\0';$i++)
{
$odd=($number[$i]%2);
echo $number[$i];
if($odd)
$oddarrold+=$number[$i];
else
$evenarr+=($number[$i]*$number[$i]);
}
$oddarr=$oddarrold*$oddarrold;
echo ($oddarr+$evenarr);
?>