Loading Now

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

Input/Output:

  • [execution time limit] 0.5 seconds 

  • [input] integer n

    1 ≤ n ≤ 109.

  • [output] integer

Post Comment

Contact