This problem extends the triangular array program from the short problems for this assignment. In the short

Program behavior

In a file triangle2.py write a recursive function triangle2(n) that returns a triangular array L of size n whose elements are defined as follows:

  • len(L[k]) = k+1 for 0 < k < N (definition of triangular arrays);
  • L[0] = [1];
  • suppose that the last element of L[i] is the integer m, then the first element of L[i+1] is m +1.

Some examples are given below.

Programming requirements

Your code must satisfy the following requirements:

1.The code to construct the triangular array must limit itself to the following Python constructs:

  • if statements
  • return statements
  • function calls (including recursive calls)
  • arithmetic and comparison operations
  • Python list operations, e.g., indexing, slicing, append, concatenation/extension, + and *

2.Helper functions are allowed for this problem.

Examples

Program Runs: see image.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.