FWIW, and for those who are interested and want to nerd out, this widget was originally prototyped in App Lab itself. Check it out: https://studio.code.org/projects/applab/AwXRD3-vtzPpAz80v0B5Ow
If you want to go look at the code, look for the function called
function calculateInverse(a,m) (around line 550) which is the crux of the whole thing. Given a number
a and a modulus
m it does a brute force search for a value
u that satisfies the equation
(u * a) mod m == 1. It is a given that
m is a prime number (because those are the only values we make available), so the solution for
u is unique.
If you check out the activity in Unit 4 Lesson 7 called "Multiplication + modulo" which gets at this idea, and what the widget is doing behind the scenes.