Recursive Function


Submit solution

Points: 20
Time limit: 2.0s
Memory limit: 64M

Authors:
Problem type

題目說明

<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

There are no comments at the moment.