A shell-script to print the pyramid of numbers.

echo -e “Enter the number::\c”

read n

for((i=1;i<=n;i++))

do

for((j=1;j<=i;j++))

do

echo -e ” $i\c”

done

echo “”

done

echo ——————–

for((i=1;i<=n;i++))

do

for((j=1;j<=i;j++))

do

echo -e ” $j\c”

done

echo “”

done

OUTPUT::

Enter the number::5

1

2 2

3 3 3

4 4 4 4

5 5 5 5 5

——————–

1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

 

 

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.