#203. 递归计算兔子耳朵总数
递归计算兔子耳朵总数
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 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 ears.
Constraints
Time limit: 1s, Memory limit: 1024 KiB for each test case.