on macbook pro:
Using the non-posix compliant array functionality results in fast code.
$ time bash p43.sh
16695334890
real 0m11.997s
user 0m15.626s
sys 0m11.549s
Making the code posix-compliant (replacing arrays w/ space-delimited strings) made the code slower, though dash
is a bit faster than bash
. I can't seem to figure out how to do exponents in dash
$(())
arithmetic blocks.
$ time bash p43.sh
16695334890
real 0m37.265s
user 0m28.518s
sys 0m22.951s
$ time dash p43.sh
16695334890
real 0m34.491s
user 0m26.244s
sys 0m22.270s