While11. An integer N (> 1) is given. Output the smallest integer K for which the sum 1 + 2 + ... + K is greater than or equal to N and the sum.

Solution in Python 3:

import random

N = random.randrange(2,200)
#N = 2
print('N = ', N)

K = 1
S = 1
while S < N:
K += 1
S += K
print("K = {0}, S = {1}".format(K,S))

print()
print("K = {0}, S = {1}".format(K,S))