Convert this recursive function to iterative
问题 How can I convert this recursive function to an iterative function? #include <cmath> int M(int H, int T){ if (H == 0) return T; if (H + 1 >= T) return pow(2, T) - 1; return M(H - 1, T - 1) + M(H, T - 1) + 1; } Well it's a 3-line code but it's very hard for me to convert this to an iterative function. Because it has 2 variables. And I don't know anything about Stacks so I couldn't convert that. My purpose for doing this is speed of the function. This function is too slow. I wanted to use map