// Numbas version: finer_feedback_settings {"name": "Numbers Week 2 -1", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"functions": {}, "ungrouped_variables": ["a", "r1", "r2", "m", "n", "a1", "r", "m1", "m2", "n1", "n2", "a2"], "name": "Numbers Week 2 -1", "tags": [], "preamble": {"css": "", "js": ""}, "advice": "
We seek a number
\n\\[r=\\var{a} \\bmod \\var{n} \\implies \\var{a} = m\\var{n}+r \\]
\nwhere $m$ is a positive integer and $0 \\le r \\le \\var{n-1}$.
\nThis is achieved by dividing $\\var{a}$ by $\\var{n}$ and we find that:
\n\\begin{align}
\\frac{\\var{a}}{\\var{n}} &= \\var{m}+\\frac{\\var{r}}{\\var{n}} \\\\
\\implies \\var{a} &= \\var{m}\\times \\var{n}+\\var{r}
\\end{align}
on multiplying through by $\\var{n}$.
\nHence $r=\\var{r}$ and $\\var{a} \\bmod \\var{n}=\\var{r}$.
\nYou can use your calculator to find this as follows:
\nDivide $\\var{a}$ by $\\var{n}$ to get
\n\\[ \\frac{\\var{a}}{\\var{n}}=\\var{a/n}=\\var{m}+\\var{a/n-m} \\]
\nThen multiplying $\\var{a/n-m}$ by $\\var{n}$ gives the remainder, i.e.
\n\\[ \\var{a/n-m}\\times \\var{n} = \\var{r} \\]
\nThis must be an integer if no error is introduced, but the calculator result will be either an integer or very close to an integer – so you need to round to the integer in that case.
\nAs in a),
\n\\[\\frac{\\var{a1}}{\\var{n1}}=\\var{m1}+\\frac{\\var{r1}}{\\var{n1}}\\]
\nSo $\\var{a1} \\bmod \\var{n1} = \\var{r1}$
\n\\[\\frac{\\var{a2}}{\\var{n2}}=\\var{m2}+\\frac{\\var{r2}}{\\var{n2}}\\]
\nSo $\\var{a2} \\bmod \\var{n2} = \\var{r2}$
", "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "parts": [{"prompt": "", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"allowFractions": false, "variableReplacements": [], "maxValue": "{r}", "minValue": "{r}", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "{r1}", "minValue": "{r1}", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry"}, {"allowFractions": false, "variableReplacements": [], "maxValue": "{r2}", "minValue": "{r2}", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry"}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}], "extensions": [], "statement": "
Find the following numbers modulo the given number $n$.
", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"a": {"definition": "m*n+r", "templateType": "anything", "group": "Ungrouped variables", "name": "a", "description": ""}, "r1": {"definition": "random(20..99)", "templateType": "anything", "group": "Ungrouped variables", "name": "r1", "description": ""}, "r2": {"definition": "random(10..19)", "templateType": "anything", "group": "Ungrouped variables", "name": "r2", "description": ""}, "m": {"definition": "random(5,6,7,8,9,11,12,13)", "templateType": "anything", "group": "Ungrouped variables", "name": "m", "description": ""}, "n": {"definition": "random(6,7,8,9,11,12,13,14,15,16,17,18,19)", "templateType": "anything", "group": "Ungrouped variables", "name": "n", "description": ""}, "a1": {"definition": "m1*n1+r1", "templateType": "anything", "group": "Ungrouped variables", "name": "a1", "description": ""}, "r": {"definition": "random(1..5)", "templateType": "anything", "group": "Ungrouped variables", "name": "r", "description": ""}, "m1": {"definition": "random(3,4,5,6)", "templateType": "anything", "group": "Ungrouped variables", "name": "m1", "description": ""}, "m2": {"definition": "random(2,3,4)", "templateType": "anything", "group": "Ungrouped variables", "name": "m2", "description": ""}, "n1": {"definition": "random(1001..1999#2)", "templateType": "anything", "group": "Ungrouped variables", "name": "n1", "description": ""}, "n2": {"definition": "random(301..999#2)", "templateType": "anything", "group": "Ungrouped variables", "name": "n2", "description": ""}, "a2": {"definition": "m2*n2+r2", "templateType": "anything", "group": "Ungrouped variables", "name": "a2", "description": ""}}, "metadata": {"description": "Modular arithmetic. Find the following numbers modulo the given number $n$. Three examples to do. Courtesy of Newcastle University
", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}], "contributors": [{"name": "Mark Hodds", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/510/"}]}]}], "contributors": [{"name": "Mark Hodds", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/510/"}]}