While13. A number A (> 1) is given. Output the smallest integer K for which the sum 1 + 1/2 + ... + 1 / K is greater than A, and this sum itself.
Solution in Python 3:
import random
A = random.randrange(2,10)
A = 7
print('A = ', A)
K = 1.0
S = 1.0
while S <= A:
K += 1
x = 1/K
S += 1/K
print("K = {0}, 1/K = {1}, S = {2}".format(K,x,S))
print()
print("K = {0}, S = {1}".format(K,S))