SKTh - Sum k th
Dữ liệu vào: Standard input
Dữ liệu ra: Standard output
Giới hạn thời gian: 1.0 giây
Giới hạn bộ nhớ: 128 megabyte
Đăng bởi: admin

The positive odd numbers are sorted in ascending order as 1,3,5,7,9,11,13,15,17,19...and grouped as (1), (3,5),(7,9,11), (13,15,17,19)... and so on.

Thus, the first group is (1), the second group is (3,5) , the third group is (7,9,11),.. etc. In general, the  group kth contains the next k elements of the sequence.

Given k , find the sum of the elements of the kth group. For example, for k = 3, the answer is : 27 (7+9+11=27)

Complete the function sumOfGroup with input integer k. Return the sum of the elements of the kth group.

Input:

-  One line contains integer \(k(0\leq k\leq 10^{6})\)

Output: sum of the elements of the kth group.

Ví dụ

  • input
    3
    output
    27
Back to Top