This example illustrates again, the rule that you can write any program with the three constructs of sequence, selection, and repetition.
The program starts in a sequence, collecting a value from the keyboard. Next, we use selection.
If the number X is smaller than 1 e.g. zero or a negative number, then an error message is printed. Otherwise, a repetitive WHILE statement is run, printing from the number 1 up until the number you have entered.
So if you entered 7 the program would print
1
2
3
4
5
6
7
as its output. Here's what the program would look like when coded in the Python programming language:
Example5.py
x = int(input('Enter Number: '))
if x < 1:
  print('Number too small')
else:
  count = 1
  while count <= x:
    print(count)
    count = count + 1