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

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

递归计算兔子耳朵总数

Bunny Ears Count

Background

In a sunny farm, there lives a group of lively and adorable bunnies. They hop around every day, bringing much joy. Congcong wants to know, if there are a certain number of bunnies on the farm, how many ears do they have in total?

Problem Description

Given a non-negative integer bunnies, representing the number of bunnies. Please use a recursive approach (without using loops or multiplication) to calculate the total number of ears across all bunnies. Each bunny has two big, floppy ears.

Input Format

Input is given from standard input in the following format.

bunnies

Output Format

Output is printed to standard output in the following format.

total_ears

Sample

0
0
1
2
2
4

Sample Explanation

For Sample 1, there are 0 bunnies, so there are 0 ears in total. For Sample 2, there is 1 bunny, so there are 1+1=21 + 1 = 2 ears in total. For Sample 3, there are 2 bunnies. This can be seen as the number of ears for 1 bunny (2 ears) plus the number of ears for the remaining 1 bunny (2 ears), totaling 2+2=42 + 2 = 4 ears.

Constraints

Time limit: 1s, Memory limit: 1024 KiB for each test case.