Question: Write two Python programs and upload them to this repostiory on GitHub. In each Python program, include the following line: if name __main_: And in


Write two Python programs and upload them to this repostiory on GitHub. In each Python program, include the following line: if name __main_": And in the DOCSTRING comment of each program, state the complexity class of the algorithm, e.g. O(log n), O(n). O(n^2), or etc. triangular.py Triangular numbers, defined on the non-negative integers, are the sum of the first n integers: n sum Triangular numbers 0 0 0 1 1 1 2 + 1 3 2 3 3 + 2 + 1 6 4 4 + 3 + 2 + 1 10 5 5 + 4 + 3+2+1 15 6 6+5+4+3+21 21 7 7 + 6 + 5+ 4 + 3+2+1 28 Write a Python program called triangular.py that produces output similar to the following: C:\> python .\triangular.py Triangular Nos n @ 1 2 3 4 5 6 7 1 3 6 10 15 21 28 This program should also include the function triang(n) that computes and returns the triangular number as the sum of the first n integers. factorial.py The factorial function, n!, also defined on the positive integers, is the product of the first n integers. n product n! 0 (by definition) 1 1 1 1 1 2+1 3 2. 3 3 + 2 + 1 6 4 4x3 x 2 x 1 24 5 5x 4 x 3 x 2 x 1 120 6 6 x 5 x 4 x 3 x 2 x 1 720 7. 7x6 x 5 x 4 x 3 x 2 x 1 5040 Write a program called factorial.py that produces the following output: C:\> python . Ifactorial.py n 1 2 3 4 5 6 7 1 1 2 6 24 120 720 5040 Your program factorial.py should have a function called fact(n) that computes and returns the factorial
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
