Looping and Skipping – HackerRank Solution

In this post, you will learn how to solve Looping and Skipping HackerRank Solution. This Looping and Skipping problem is a part of Linux Shell series.

So, without further ado, let’s begin this tutorial.

Task

Your task is to use for loops to display only odd natural numbers from 1 to 99.

Input Format

There is no input.

Constraints

Output Format

1
3
5
.
.
.
.
.
99  

Sample Input

-

Sample Output

1
3
5
.
.
.
.
.
99  

Solution – Looping and Skipping – HackerRank Solution

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

Note: This problem (Looping and Skipping) is generated by HackerRank but the solution is provided by CodingBroz. This tutorial is only for Learning and Educational purpose.

Leave a Comment

Your email address will not be published.