Solve array challange on php

Code is :

$array = array(1,2,3,5,8,13,21,34,55);

$sum = 0;
echo "i = array(i) = array(array(i))
";
for( $i=0;$i<5 br="" i="">  echo $i. " = ".$array[$i] . "        = " .$array[$array[$i]]."
";
  $sum += $array[$array[$i]];
}

echo $sum;

Output :

i = array(i) = array(array(i))
0 = 1        = 2
1 = 2        = 3
2 = 3        = 5
3 = 5        = 13
4 = 8        = 55
78

Comments

Popular posts from this blog

N Queen Problem using c and c++

Greedy Prim Algorithm using c/c++

m Coloring Problem using c or c++