斐波那契: 1 1 2 3 5 8 .....
特点:后面的数等于前面两个数之和, 即 f ( n )= f ( n-1 ) + f ( n-2 ) ;
代码
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>递归求斐波那契数</title>
</head>
<body>
<script>
function fbnq(n){
if(n==1||n==2){
return 1;
}
return fbnq(n-1)+fbnq(n-2);
}
console.log(fbnq(3));
</script>
</body>
</html>