blob: 4dd5499a0fe68a80101278d33e7cbd84e3d22e1c [file] [log] [blame]
#!/bin/bash
# Fibonacci numbers
# Writes an infinite series to stdout, one entry per line
function fib() {
local a=1
local b=1
while true ; do
echo $a
local tmp=$a
a=$(( $a + $b ))
b=$tmp
done
}
# output the 10th element of the series and halt
fib | head -10 | tail -1