How is it exponential time? It should be linear as it loops through at most `n` times. My guess is that it would also be optimized for tail recursion so it wouldn't clobber the call stack either.
That said - you're right that it's still slower than constant time