Looping with Numbers in Bash Programming Tutorial Hacker rank – Solution in Bash

Hackerrank - Bash Tutorials Hackerrank Online Judge Solution

Hackerrank – Looping with Numbers in Bash Programming Tutorial Hacker rank – Solution in Bash

Problem:

Looping with Numbers in Bash Programming Tutorial Hacker rank.
Output Format
1
2
3
.
.
.
.
.
50

Solution in Bash Programming Language:

#!/bin/bash
for i in {1..50..1};
do
echo $i;
done

Explanation:
So go to our code. In this line,
for i in {1..50..1};
We take a simple for loop that will go 1 to 50  and that will do one increment.
  • 1 is first value of i
  • 50 is the last value of i
  • 1 is the increments of i
That’s the code. Then just echo or print the i variable. In Bash the variable is printed a dollar sign first, $.
The for loop is completed by done text.
Tags:
Hacker-rank tutorials, Looping and Skipping – Bash Tutorials Solution, Bash Loop, Bash For Loop, Bash Loop System, Hackerrank Online Judge Solution, Hackerrank – Bash Tutorials, Looping with Numbers in Bash Programming Tutorial Hacker rank – Solution in Bash

Leave a Reply

Your email address will not be published.