
cakeSlice
A cake is sliced with n
straight lines. Calculate the maximum number of pieces the cake can have.
Example:
- For
n=0
, the output should beCakeSlices(n) = 1
For
n=1
, the output should beCakeSlices(n) = 2
- For
n=2
, the output should beCakeSlices(n) = 4
For
n=3
, the output should beCakeSlices(n) = 7
Input/Output:
-
[execution time limit] 0.5 seconds
-
[input] integer n
0 ≤ n ≤ 100
-
[output] integer
The maximum number of pieces the sliced cake can have.
Post Comment