qq_青枣工作室_0
<?php
$a=1;
$b=2;
$sum = 0;
$expList = []; // 这里仅用于演示计算项
$n=9; // 前N项(N<10)
while($n--) {
$sum += $a/$b;
$expList[] = "$a/$b";
$_a = $a;
$a = $b;
$b = $_a+$b;
}
echo implode(' + ', $expList) . ' = ';
echo $sum;输出:1/2 + 2/3 + 3/5 + 5/8 + 8/13 + 13/21 + 21/34 + 34/55 + 55/89 = 5.4799053061941