// Numbas version: exam_results_page_options {"name": "Multiplicative inverse", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Multiplicative inverse", "tags": [], "metadata": {"description": "

Asks students to compute the multiplicative inverse of $a$ in $\\mathbb{Z}_n$ where $n$ is an odd number between 31 and 61 and $a$ is an integer coprime to $n$ that lies between $n/4$ and $3n/4$.

", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "statement": "

Determine the inverse of $\\var{a}\\pmod{\\var{n}}$.

", "advice": "

We observe that {a} is coprime to {n} and thus has a multiplicative inverse.  We use the Extended Euclidean Algorithm to determine that $1=\\var{smatrix[0][k]}\\cdot\\var{n}+\\var{tmatrix[0][k]}\\cdot\\var{a}$, and so the inverse of {a} is $\\var{mod(tmatrix[0][k],n)}$.

", "rulesets": {}, "extensions": [], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"n": {"name": "n", "group": "Ungrouped variables", "definition": "random(31 .. 61#2)", "description": "", "templateType": "randrange", "can_override": false}, "a": {"name": "a", "group": "Ungrouped variables", "definition": "Random(floor(n/4)..3*floor(n/4))", "description": "", "templateType": "anything", "can_override": false}, "calcs": {"name": "calcs", "group": "Ungrouped variables", "definition": "iterate_until([(r2-mod(r2,mod(r1,r2)))/mod(r1,r2),r2,mod(r1,r2),s2,s1-q*s2,t2,t1-q*t2],[q,r1,r2,s1,s2,t1,t2],[(n-mod(n,a))/a,n,a,1,0,0,1],[q,r1,r2,s1,s2,t1,t2][2]=0)", "description": "", "templateType": "anything", "can_override": false}, "tmatrix": {"name": "tmatrix", "group": "Ungrouped variables", "definition": "matrix(map(calcs[i][5],i,0..k))", "description": "", "templateType": "anything", "can_override": false}, "k": {"name": "k", "group": "Ungrouped variables", "definition": "len(calcs)-1", "description": "", "templateType": "anything", "can_override": false}, "inverse": {"name": "inverse", "group": "Ungrouped variables", "definition": "mod(tmatrix[0][k],n)", "description": "", "templateType": "anything", "can_override": false}, "smatrix": {"name": "smatrix", "group": "Ungrouped variables", "definition": "matrix(map(calcs[i][3],i,0..k))", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "gcd(a,n)=1 ", "maxRuns": 100}, "ungrouped_variables": ["n", "a", "calcs", "k", "tmatrix", "inverse", "smatrix"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": "3", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

(Express your answer as an integer between $0$ and $\\var{n-1}$ inclusive.)

", "minValue": "inverse", "maxValue": "inverse", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Maura Paterson", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7001/"}]}]}], "contributors": [{"name": "Maura Paterson", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7001/"}]}