Question: python/data programming Problem 4: Factorial Use a for loop to compute 101, the factorial of 10. Recall that the factorial of n is 1*2*3'...'n. [Note:
Problem 4: Factorial Use a for loop to compute 101, the factorial of 10. Recall that the factorial of n is 1*2*3'...'n. [Note: you may not use the math.factorial function for this problem or any other problem in this homework. You should also NOT use recursion. (If you do not know what that means, do not worry because you should not use it :-) Hint: Your answer will be similar to your answer to "Problem 3: Triangular numbers". As in Problem 3. your code should be able to calculate 111, 12), or any other number's factorial just by changing the first line to set n to 11, 12, or any other number. Be sure the code you submit calculates the factorial for n = 10. Problem 5: Multiple factorials Write code to print the first 10 factorials, in reverse order. In other words, write code that prints 101, then prints 91, then prints 81, ..., then prints 1. Its literal output will be: 101: 3628800 91: 362880 81: 40320 71: 5040 61: 720 51: 120 4!: 24 31: 6 21: 2 11: 1 The first line of your solution should assign a variable num_lines to 10. Then, as in Problems 3 and 4, the rest of the code should print the correct number of lines and correct factorial on each line for values other than 10 just by setting num_lines to a different value. Hint: Use two nested for loops. The outer loop sets the value of n to the values num_lines, num_lines-1, num_lines-2, ..., 1, in succession. Then, the body of that loop is itself a loop - exactly your solution to "Problem 4: Factorial", without the first line n 10 that hard-codes the value of n
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
