Recursive Function
題目說明
<1124檢定考題>
函數定義如下:
\[ f(n) = \begin{cases} 5\times f(n-3)+3\times f(n-2)+f(n-1)+1 & \text{if n≥3 }\\ n & \text{if n<3 } \end{cases} \]
請設計程式,由鍵盤輸入一正整數n,由螢幕輸出f(n)值。
sample input1
4
sample output1
18
sample input2
7
sample output2
364
sample input3
3
sample output3
6
Comments