Series15. An integer K and a set of non-zero integers are given; The sign of its completion is the number 0. Output the sequence number of the first number in the set that is greater than K. If there are no such numbers, output 0.

Solution in Python 3:

import random

K = random.randrange(2,8)
print("K = ",K)

x = random.randrange(1,5)
print(x,end='; ')
k = 0
N = 0
flag = True
while x != 0:
if x > K and flag:
flag = False
N = k + 1
k += 1
x = random.randrange(-5,7)
print(x,end='; ')

print()
print("Amount of numbers:",k)
print("Serial number of first greater than K:",N)