Series22. An integer N (> 1) and a set of N real numbers are given. If this set forms a decreasing sequence, then output 0; Otherwise, output the number of the first number that violates the pattern.

Solution in Python 3:

import random

N = random.randrange(2,20)
print("N = ",N)

#x = N
x = random.randrange(1,10)
x_prev = x
flag = True
for i in range(1,N):
#x = N-i
x = random.randrange(1,10)
if x_prev <= x:
flag = False
#break
print(x_prev,end="; ")
x_prev = x
print(x)

print("Result = ",flag)