function getNum($n){
//获取1-100的阶乘
for ($i=1;$i<=$n;$i++){
$res += $i;
}
return $res;
}
print getNum(100);
function getNum($n){
//获取1-100的阶乘
$sum= $i = 0;
while( $i<= $n ) {
$sum += ( $i++ );
}
echo $sum;
}
print getNum(100);
echo array_sum(range(1,100)); //array_sum 获取数字内元素之和 range获取参数var1-var2填充元素 组合表示array_sum(1,2,3,4,5,...,100);