Loops in Python - Hacker Rank Solution

Task

The provided code stub reads and integer, , from STDIN. For all non-negative integers i<n, print i^2.


Example

n = 3

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

0
1
4


Input Format

The first and only line contains the integer, n.


Output Format

Print n lines, one corresponding to each i.


Sample Input 0

5


Sample Output 0

0
1
4
9
16


Explanation




Solution

1
2
3
4
if __name__ == '__main__':
    n = int(input())
    for i in range(0,n):
        print(i*i)
Next Post Previous Post
1 Comments
  • Sushant Arbole
    Sushant Arbole September 25, 2021 at 1:18 PM

    Thanks for the code it worked successfully .....

Add Comment
comment url