Memory allocated on the stack is freed at the function exit, so reduce iteration count to avoid stack overflow