Define a generator squares that produces an infinite sequence of the squares of all natural numbers (1, 4, 9, 16, ...).
For a given number n, print out the first n elements each on a new line.
Define a generator squares that produces an infinite sequence of the squares of all natural numbers (1, 4, 9, 16, ...).
For a given number n, print out the first n elements each on a new line.
Sample Input 1:
2Sample Output 1:
1
4Sample Input 2:
5Sample Output 2:
1
4
9
16
25Create a free account to access the full topic