You both may be running with different memory constraints. There are three issues: tail recursion, memory, and the cast.
The cast is likely a loop repl issue. You can increase your memory. The function isn't tail recursive from what I know of tail recursion, but it could be a loop-specific construct I'm not aware of (haven't played with it much).
Dave
(pardon brevity, typos, and top-quoting; on cell)