Loops

Task
The provided code stub reads and integer, i, from STDIN. For all non-negative integers i, print i².

Example

The list of non-negative integers that are less than n = 3 is [0,1,2]. Print the square of each number on a separate line.

0
1
4

Input Format

The first and only line contains the integer, n.

Constraints

1 ≤ n ≤ 20

Output Format

Print n lines, one corresponding to each i.

Sample Input 0

5

Sample Output 0

0
1
4
9
16

Solution(Python 3):

if __name__ == '__main__':
n = int(input())
i = 0
while i < n:
print(i**2)
i += 1

Link

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Isabelle

Isabelle

In love with telling stories with data