PROBLEM 1 - FACTORIAL: Write a function prodN(n) taking as parameter an integer n.
• If n is positive, the function returns the product of the first n natural numbers.
• If n is zero, the function returns 1.
• If n is negative or is not an integer, the function returns None.
Remember to extensively test your program to make sure it works
properly.

def prodN(n):
if type(n) != type(0) or n < 0:
return
result = 1
for i in range(1, n+1):
result = result * i
return result
print(prodN("Chegg"))
print(prodN(-20))
for i in range(1,6):
print(i, "prodN =", prodN(i))
# Hit the thumbs up if you are fine with the answer. Happy Learning!|
PROBLEM 1 - FACTORIAL: Write a function prodN(n) taking as parameter an integer n. • If...
Write a method named factorial that accepts an integer n as a parameter and returns the factorial of n, or n!. A factorial of an integer is defined as the product of all integers from 1 through that integer inclusive. For example, the call of factorial(4) should return 1 2 3 4, or 24. The factorial of 0 and 1 are defined to be 1. You may assume that the value passed is non-negative and that its factorial can fit...
DONE IN PYTHON The factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example, 5 ! = 5 × 4 × 3 × 2 × 1 = 120. The value of 0! is 1. Write a program, with comments, to do the following: 20 points Ask the user to enter a positive integer n. between 1 and 20 ; You may assume the user will enter...
Write a recursive function named arithmeticSum that takes a positive integer parameter n and returns the sum of the integer numbers from 1 to n Please write in C++
In Java Write a method factorial that accepts an integer parameter n and that uses recursion to compute and return the value of n factorial (also known as n!). Your method should throw an IllegalArgumentException if n is negative. Several calls and their return values are shown below. Call Output factorial(0); 1 factorial(1); 1 factorial(3); 6 factorial(5); 120 factorial(10); 3628800 factorial(-4); IllegalArgumentException
C++ [10pts] Write a function that takes as a parameter an integer (as a long value) and returns the number of odd, even, and zero digits. Also write a program to test your function.
Written in expanded form, the usual factorial function is n! = n middot (n - 1) middot (n - 2) ... 3 middot 2 middot 2 middot 1. The difference between elements in the product is always 1. It can be writ in recursive form as n! = n middot (n - 1)! (e.g., 10! = 10 middot 9!, 23! * 23 middot 22!, 4! = 4 3!, etc.). The purpose of this problem is to generalize the factorial function...
Write a function that takes an integer input n as a parameter and after it calculates the sum of 1+2+3+...+n, it returns the value to the main program. For example, if n=4, the output of the sum will be 10.
c++ please
(1) Write a program that prompts the user to enter an integer value N which will rpresent the parameter to be sent to a function. Use the format below. Then write a function named CubicRoot The function will receive the parameter N and return'its cubic value. In the main program print the message: (30 Points) Enter an integer N: [. ..1 The cubic root of I.. ] is 2 update the code om part and write another function...
In Python Use the Design Recipe to write a function factorial that when given a positive integer calculates the factorial. If given a negative integer or not an integer), the function should return None. If given 0, it should return 1. Include a docstring! Note: You may assume all arguments passed to this function will be numeric. Write three assertEqual statements to test your function. To test and receive credit for your assertEqual statements, copy them into Part E and...
Write a C++ function to find factorial of an integer number N >0. Using the factorial function print the factorial of two inputs as shown below: Sample input: 1 4 Expected output: 1 24