今更だけどアッカーマンの展開ループです
https://ideone.com/dKocyf

これループに直せません?
https://ideone.com/Ub1M86