Starting from:

$30

CECS229 - Lab Programming Assignment #2 - Solved

1.       (10 points)

Write a function that will take in three inputs: base, exponent, and divisor. The output would be the product of the values of the modulus operations, such that when taking that as the modulus of the divisor, you will get the problem’s remainder.  

 

Function name should be modulus_product. Do not print anything out. Comment out or delete your test cases.

 

Example:  

modulus_product(3,644,645) means 3644 mod 645. The function’s output should be 3560436, because 81, 396, 111 are the remainders used in finding the overall problem’s remainder, and 81 x 396 x 111 = 3560436. See the screenshot below for further details.  

 

  

 

 

2.       (10 points)

Write a function, isPrime(L). input:  

                           L - list of numbers greater than 1.

output: numbers from that list that are prime  

example: isPrime([2, 5, 8, 10, 13]) will return [2, 5, 13]

 

More products