Pascal's triangle: Difference between revisions

add UNIX Shell
(add UNIX Shell)
Line 3,263:
0 OK, 0:380
</pre>
=={{header|UNIX Shell}}==
{{works with|Bourne Again SHell}}
<lang bash>#! /bin/bash
pascal() {
local -i level=${1:-1} n
if (( level <= 1 )); then
echo 1
else
local output=$( $FUNCNAME $((level - 1)) )
set -- $( tail -n 1 <<<"$output" ) # previous row
echo "$output"
n=0
for arg do
printf "%d " $((n + arg))
n=$arg
done
echo 1
fi
}
pascal "$1"</lang>
 
=={{header|Ursala}}==
Zero maps to the empty list. Negatives are inexpressible.
Anonymous user