Calculate the Nth term

  • + 0 comments

    How Recursion works:

    Here’s a step-by-step breakdown of how to calculate the 8th term of a series using recursion, showing the full expansion, substitution, and simplification process.

    Expanded Breakdown for:

    return find_nth_term(n - 1, a, b, c) + find_nth_term(n - 2, a, b, c) + find_nth_term(n - 3, a, b, c);

    Here's the full recursive breakdown:

    n = 8 , a = 1, b = 2, c = 3

    n8 = (n7 + n6 + n5)

    n8 = ((n6 + n5 + n4) + (n5 + n4 + n3) + (n4 + n3 + n2))

    n8 = (((n5 + n4 + n3) + (n4 + n3 + n2) + (n3 + n2 + n1)) + ((n4 + n3 + n2) + (n3 + n2 + n1) + n3) + ((n3 + n2 + n1) + n3 + n2))

    n8 = ((((n4 + n3 + n2) + (n3 + n2 + n1) + n3) + ((n3 + n2 + n1) + n3 + n2) + (n3 + n2 + n1)) + (((n3 + n2 + n1) + n3 + n2) + (n3 + n2 + n1) + n3) + ((n3 + n2 + n1) + n3 + n2))

    n8 = (((((n3 + n2 + n1) + n3 + n2) + (n3 + n2 + n1) + n3) + ((n3 + n2 + n1) + n3 + n2) + (n3 + n2 + n1)) + (((n3 + n2 + n1) + n3 + n2) + (n3 + n2 + n1) + n3) + ((n3 + n2 + n1) + n3 + n2))

    Substituting values:

    n8 = (((((3 + 2 + 1) + 3 + 2) + (3 + 2 + 1) + 3) + ((3 + 2 + 1) + 3 + 2) + (3 + 2 + 1)) + (((3 + 2 + 1) + 3 + 2) + (3 + 2 + 1) + 3) + ((3 + 2 + 1) + 3 + 2))

    n8 = ((((6 + 5) + 6 + 3) + (6 + 3 + 2) + 6) + ((6 + 5) + 6 + 3) + (6 + 3 + 2))

    n8 = (((11 + 6 + 3) + 11 + 6) + (11 + 6 + 3) + 11)

    n8 = ((20 + 11 + 6) + 20 + 11)

    n8 = (37 + 20 + 11)

    n8 = 68