如下:
//1 1 2 3 5 8 13 21...
//斐波拉切 function fei(n){ if(n==1 || n==2){ return 1 }else{ return fei(n-1)+fei(n-2) } } console.log(fei(7))
如下:
//1 1 2 3 5 8 13 21...
//斐波拉切 function fei(n){ if(n==1 || n==2){ return 1 }else{ return fei(n-1)+fei(n-2) } } console.log(fei(7))