function fibnaqu(num){
if(num==0 || num==1 || num==2){
return num
}else{
result = fibnaqu(num-1)+fibnaqu(num-2)+fibnaqu(num-3)
return result
}
}
console.log(fibnaqu(5))
单个叶子节点获益2,双叶子节点获利5,求最大获益
let big=0
let p =0
function price(root){
let num =0
if(root.left && root.right){
p+=5
num=5
}else if(root.left || root.right){
p+=3
num=3
}else{
num=0
if(big<p){
big=p
}
}
if(root.left) left=price(root.left)
if(root.right) right = price(root.right)
p-=num //回退的时候减去因自己孩子节点所增加的num
}
price(a)
console.log(big)