+1(805) 568 7317

python a write a function named mersenne that takes as input a number n and outputs 5192359


a) Write a function named mersenne() that takes as input a number n and outputs the number 2n-1. These are called Mersenne numbers*. For example, the second Mersenne number is 22-1 = 3, the fifth Mersenne number is 25-1 = 31, and the nineteenth Mersenne number is 219-1 = 524287.

Hint: This is a pure function. So if print() or input() appear in the function definition, then the problem will be rejected.

b) Write a script that includes the definition of mersenne() that you just wrote. When the script is executed, it should ask the user to input 3 numbers and then use themersenne() function to print out the corresponding 3 Mersenne numbers. So if the user types in 2, 5, and 19, the script will display (on the screen) something like Your Mersenne numbers are 3, 31, and 524287.

Hint 1: The script you write here should use both input() and print() because the instructions specifically mention taking input from the user and displaying results on the screen.

Hint 2: You should be using the function you wrote in part (a), not copying it. The only place that arithmetic operators (like – and **) should appear is inside the definition you wrote in part (a). Instead of repeating the arithmetic, you should be using the function you just wrote.

"Order a similar paper and get 15% discount on your first order with us
Use the following coupon

Order Now