Question: Please write this function in python. Do not use loops. Here are the Annoying Requirements: In annoying_recursion_part2.py, write a function, annoying_triangleNumbers (n), which returns the

Please write this function in python.

Do not use loops.

Please write this function in python. Do not use loops. Here are

Here are the Annoying Requirements:

the Annoying Requirements: In annoying_recursion_part2.py, write a function, annoying_triangleNumbers (n), which returns

In annoying_recursion_part2.py, write a function, annoying_triangleNumbers (n), which returns the sum 1+2+3...+n. Triangle numbers (https://en.wikipedia.org/wiki/Triangle_numbers) are calculated by summing up all of the values from 1 to n. Back in Algebra class, you probably learned that you can calculate that sum, quite easily, with the formula n(n+1) That's nice - but we're not going to use it. Instead, 2 you're going to write a function that calculates it recursively. This function must obey the Annoying Requirements. 2.1 4 Base Cases Every annoying" function must have special cases for the values 0,1,2,3. For each of these values, you must implement it as a base case - that is, simply return or print) the answer - without any recursion at all. 2.2 3 Hard-Coded, but Recursive Cases Every "annoying" function must also have special cases for the values 4,5,6. These must be implemented recursively, but you must hard-code what you recursively call. That is, don't use the value n in those cases at all (except to figure out that you are in that case). So, for instance, the factorial function might include this snippet: if n == 5: return 5 * annoying_factorial (4) 2.3 The General-Purpose Case Finally, every "annoying" function must have a general case. (This is what would be the body of the recursive in a more typical solution. This general case: Must not execute except for n > 7. (But it must work properly for all such large values!) Must recurse

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!