Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

QUESTION 19 Extra credit: what does the following Python function do? [96 is the

ID: 2262100 • Letter: Q

Question

QUESTION 19 Extra credit: what does the following Python function do? [96 is the mod operator. / is integer division, i e. division, followed by floor. For example, 7 96 3 evaluates to 1, 7//3 evaluates to 2, put differently, both functions execute the division algorithm; // finds the quotient, 9% the remainder. def function(b.n,d) defines a function with inputs b.n and d.] def function (b,n, d): result 1 while n > 0: retarn result It returns b" mod d using fast modular exponentiation. o It executes the division algorithm n=bd + r and returns the value r Cresult o It retums lcm(b,n,d) using the Euclidean algorithm. It returns b" mod d using slow modular exponentiation.

Explanation / Answer

ANSWER:

It returns bn mod d using fast exponentiation method.

The exponentiation is fast as at each step b = b* b % d is done so modulo division is done at each step and previous step result is used in the next step which makes it fast without repeating.