Series16. An integer K and a set of non-zero integers are given; The sign of its completion is the number 0. Output the number of the last number in the set larger 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
while x != 0:
if x > K:
N = k + 1
k += 1
x = random.randrange(-5,7)
print(x,end='; ')

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