/** 递归**/
func
tion row($a)
{
if($a<=0)
{
$a = 0;
}
else if($a==1 || $a==2)
{
$a = 1;
}
else
{
$a = row($a-1)+row($a-2);
}
return $a;
}
echo row(20);
/**非递归**/
function row($one)
{
$two=$three=1;
$four=1;
for($i=3;$i<=$one;$i++)
{
$two=$three;
$three=$four;
$four = $two+$three;
}
return $four;
}
echo row(20);