#205. 递归计算兔子耳朵总数

    ID: 205 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatWarmup-2gesp5递归条件结构

递归计算兔子耳朵总数

Recursive Bunny Ears

Background

Congcong loves small animals, especially cute bunnies. He noticed that different bunnies have different numbers of ears.

Problem Description

We have bunnies standing in a line, numbered 1,2,1, 2, \dots. The odd bunnies (1,3,1, 3, \dots) have the normal 22 ears. The even bunnies (2,4,2, 4, \dots) we'll say have 33 ears, because they each have a raised foot. Recursively return the number of "ears" in the bunny line 1,2,,n1, 2, \dots, n (without loops or multiplication).

Input Format

Input is given from Standard Input in the following format.

An integer nn, representing the length of the bunny line.

Output Format

Output is printed to Standard Output in the following format.

An integer, representing the total number of ears for the first nn bunnies.

Sample

0
0
1
2
2
5

Sample Explanation

For n=0n=0, there are no bunnies, so the total number of ears is 00. For n=1n=1, there is only bunny 11, which is odd-numbered and has 22 ears. Total is 22. For n=2n=2, there are bunny 11 and bunny 22. Bunny 11 is odd-numbered and has 22 ears. Bunny 22 is even-numbered and has 33 ears. Total is 2+3=52 + 3 = 5.

Constraints

Time limit: 11 second, Memory limit: 10241024 KiB for each test case.