Just found a bug in pdksh version 5.2.14 – it cannot handle integers arrays correctly (pdksh is the Public Domain Korn Shell). I first discovered this with a lottery script, but actually it is very easy to reproduce:
typeset –i array
gives: 45 45 45 45
This works correctly if typeset –i is not used. Bash, with declare –ia array, works fine, as you might expect.