
maxNumberOfTerms
For a given n
find the maximum number k
, such that n
can be represented as the sum of k
different natural terms.
Example:
- For
n = 4,
the output should beMaxNumberOfTerms(n) = 2
, because1+3=4
- For
n = 6,
the output should beMaxNumberOfTerms(n) = 3
, because1+2+3=6
Input/Output:
-
[execution time limit] 0.5 seconds
-
[input] integer n
1 ≤ n ≤ 109.
-
[output] integer
Post Comment