
97
7.9 | GENERATE A SERIES
7.9 | Generate a Series
Example 7.8
Purpose: Application of nested loops.
Problem
Generate and store the following series up to N terms. Value of N is available in location 30H. e series is
presented using decimal number system.
1, 2, 3, 11, 12, 13, 21, 22, 23, 31, … up to N terms.
Solution
A careful study reveals that the series contains only natural numbers with some regular gaps. After fi rst
three terms, there is a gap of seven numbers and the pattern repeats. erefore, two consecutive loops
may be planned whose fi rst one to be repeated three times and the second one for seven times. Moreover,
there must be a counter ...