Loading Now

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 be CakeSlices(n) = 1
  • For n=1, the output should be CakeSlices(n) = 2
  • For n=2, the output should be CakeSlices(n) = 4
  • For n=3, the output should be CakeSlices(n) = 7
  • CakeSlices

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

Contact