Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- calcElement(){
- num=1
- for(( a=$i; a>1; a-- )){
- let num*=a
- }
- den1=1
- for(( a=$j; a>1; a-- )){
- let den1*=a
- }
- den2=1
- for(( a=$i-$j; a>1; a-- )){
- let den2*=a
- }
- ans=$(( num / (den1*den2) ))
- }
- echo -n "Enter the number of rows: "
- read n
- for(( i=0; i<$n; i++ )){
- for(( space=$n-$i-1; space>=0; space-- )){
- echo -n " "
- }
- for(( j=0; j<=i; j++ )){
- calcElement
- echo -n "$ans "
- }
- echo ""
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement