BASH
#!/bin/bash
row=1
while [[ $row -le 47 ]]; do
printf "%03d: " $row
for (( col=$row; col > 0; col-- )); do
if [[ ${col} -eq 1 ]]; then
cell[${col}]=1
elif [[ ${col} -eq ${row} ]]; then
cell[${col}]=1
else
cell[${col}]=$(( ${cell[${col}-1]}+${cell[${col}]} ))
fi
done
for (( col=1; col <= ${row}; col++ )); do
printf "%15d " ${cell[${col}]}
done
echo
row=$((row+1))
done
Comments
Post a Comment