Transcribed Image Text: Q: Code using C++

Transcribed Image Text: Q: Code using C++
You are given two integers, n and m. You want to make m equal to 0. You decide
to keep repeating the following operation until m becomes 0:
• Choose an integer r, uniformly at random from the range [1, n]. Set m equal
to the remainder obtained on dividing it by r. That is, replace m with m%r,
where % denotes the modulo operator.
Find the expected number of operations after which m becomes 0. Let the answer
be equal to E = for some integers Pand Q such that gcd(P, Q) = 1. Output
the value of PQ modulo 10° + 7, where Q’ denotes the modular inverse of
Q modulo 10° + 7.


Buy plagiarism free, original and professional custom paper online now at a cheaper price. Submit your order proudly with us

Essay Hope