+ 1
I am new to php can any one explain why the ans is 10?
function func($arg){ $result=0; for($i=0;$i<$arg;$i++){ $result=$result+$i; } return $result; } echo func(5);
5 Respostas
+ 12
It's not just PHP but it is also the same with JavaScript
+ 10
when i=0 0+0=0,
when i=1 0+1=1,
... 1+2=3,
... 3+3=6,
... 6+4=10
+ 1
thank you Elizabeth & Siddharth
+ 1
Now I expect the answer is 10.
0
btw s
what you expect?