A PHP interview question, I feel that my writing is not very elegant. I would like to see how you write it.

A lamb can live to be 5 years old. It gives birth to a lamb at the age of 2 and 4, and dies at the age of 5.
Q: now there is a newborn lamb (how many sheep will there be after the age of 0), n?

Dec.23,2021

the first type:

function fn($x){
    $arr=[0=>0,1=>1,2=>2,3=>2,4=>4];
    if($x<=4)return $arr[$x];
    return fn($x-2)+fn($x-4);
}
echo fn(10);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38acd-406bd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38acd-406bd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?