递归方程:
[egin{cases}
f(n)=2f(n-1)+1 &(n>1)&\
f(1)=2 &(n=1)&
end{cases}
]
构造生成函数求解:
[egin{array}{lcl}
G(x)=2x^1+5x^2+11x^3+23x^4+cdots\\
2xcdot G(x)=; +4x^2+10x^3+22x^4+cdots\\
(1-2x)G(x)=2x+x^2+x^3+x^4+cdots\\
qquadqquadqquad =x+(x+x^2+x^3+x^4+x^5+cdots)\\
qquadqquadqquad=x+frac{1}{1-x}-1=x+frac{x}{1-x}\\
G(x)=frac{x}{1-2x}+frac{x}{(1-2x)(1-x)}\\
qquad;\, =frac{x}{1-2x}+frac{1}{1-2x}-frac{1}{1-x}\\
qquad;\,=(2^0x+2^1x^2+2^2x^3+cdots)+(2^1x^1+2^2x^2+2^3x^3+cdots)\\
qquadqquad-(1+x+x^2+x^3+x^4+cdots)\\
G(x)=(2^1+2^0-1)x+(2^2+2^1-1)x^2cdots+(2^n+2^{n-1}-1)x^n+cdots\\
Rightarrow f(n)=2^n+2^{n-1}-1
end{array}
]