I have a recursive algorithm and I want to make it iterative

I found this command

RecurrenceTable[eqns, expr, {n, n_max]}]

but I don't know how I make my recurrence relation because there is two possibility and there is a sum, I also found this

NestWhileList[f, expr, test, m]

I don't know if they work with my algorithm or not I don't found a good explanation about them.

g[n_, l_,  h_] := g[n, l, h] = 
      If[n == 0, If[l == 1 , If[h < 2, x^h, 0], x^h], 
          Sum[If[j == l , 0, g[n - 1, j, Max[h, j]]], {j, 1, h + 1}]]; 
               T[n_] := Function[p, Table[Coefficient[p, x, i], {i, 0, n}]][
                    g[n, 0, 0]]; Grid[Table[T[n], {n, 0, 7}]]

Thank you.

  • $\begingroup$ Try FindSequenceFunction. $\endgroup$ – JungHwan Min Aug 20 '16 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.