Question: Introduction In this assignment you will use functions to generate famous mathematical number sequences, namely Catalan numbers and the Pascal Triangle. Rather than writing a




Introduction In this assignment you will use functions to generate famous mathematical number sequences, namely Catalan numbers and the Pascal Triangle. Rather than writing a single, monolithic piece of code, you'll create a function that can then be called by your main method to accept a parameter(s) and produce the proper results Skills: logical operators, loops, functions, recursion Catalan Numbers Catalan numbers are used to answer the question: "In how many ways can a regularn-gon be divided into 1-2 triangles if different orientations are counted separately . AT&T 4:29 PM 18 30% 4 JHU_IntroPython_Module6_Assignm... .. Catalan Numbers Catalan numbers are used to answer the question how many wayscanaren gobe divided into tres afferent rentations are counted partly They are gerated by the following formula where the capital symbol is the multiplication equivat of capital sig for addition fien 20 Pascal's Triangle . AT&T 4:30 PM 31% 4 JHU_IntroPython_Module6_Assignm... Pascal Triangle Pescar's Triane ka triangular array of Bicomial.cecients. There are number of interesting characteristics The outer left and diagonal consists of all y's 2 The second diagonal is formed by adding to the previous dit fouting numbers The third agonal consists of triangular numbers 4. The sum of elements in each row forms powers of 21.2.4.& 16. 5 The present in the triangle tool You may also notice that each element in the triangles formed by the these acerator show in blue. We will be using this fact to recursively bulda Pascal Triangle . AT&T 4:30 PM 31% 4 JHU_IntroPython_Module6_Assignm... ... Programming Assignment Part 1 Catalan Numbers Create a file called catalon.pythmethod containing a loop for 2.1-15 the calls function named 'catata which takes an interament and return the Catalan number of ondern Your 'man' method should call your function each time through the loop and output the results to the con in the following format 42 - 1420 alan sun 16796 Order 11 Catalan sur 706 Peder a Catalan - 201012 Dedet 13 Omber 942900 Orde 14 Catalan er 2674440 Order_catalanes 9694045 Programming Assement Part 2: Pascal's Triangle Create a file named pascalpy that we method to call recarsi function named which . AT&T 4:30 PM 31% 4 JHU_IntroPython_Module6_Assignm... Programming Assignment Part 2 Pascal's Triangle Create a file named postalpy that uses a method to call a recursive function named "pascal' which accepts an integer as a parameter and print the order in Pascal Triangle to the console. For this assignment you will generate the Pascal Triangle for 30. As a hint, your function will turn the current positions at the beginning or end of a row, there I wil recursively return the sum of the two cent entries above the current position in the triangle Here's a dagam to help demonstrate the relation between the contentement and the docent ements above it www. rowe Please note that your pascal' function MUST be recursive it must call itself. There are approaches to this that are iterative, but that's not what's being asked for here. Your final output should resemble triangle and have each element separated by a space as shown below. 1mple Solution So to su Solution 6 15 20 15 6 1 1721 35 35 21 71 1.8 28 56 70 56 20 01 9 36 94 126 126 94 36 91
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
