// Numbas version: exam_results_page_options {"name": "Find numbers modulo a base", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [], "variables": {"r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(20..99)", "description": "", "name": "r1"}, "a": {"templateType": "anything", "group": "Ungrouped variables", "definition": "m*n+r", "description": "", "name": "a"}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(5,6,7,8,9,11,12,13)", "description": "", "name": "m"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(6,7,8,9,11,12,13,14,15,16,17,18,19)", "description": "", "name": "n"}, "n1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1001..1999#2)", "description": "", "name": "n1"}, "a1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "m1*n1+r1", "description": "", "name": "a1"}, "m1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3,4,5,6)", "description": "", "name": "m1"}, "n2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(301..999#2)", "description": "", "name": "n2"}, "r": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1..5)", "description": "", "name": "r"}, "m2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2,3,4)", "description": "", "name": "m2"}, "r2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(10..19)", "description": "", "name": "r2"}, "a2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "m2*n2+r2", "description": "", "name": "a2"}}, "ungrouped_variables": ["a", "r1", "r2", "m", "n", "a1", "r", "m1", "m2", "n1", "n2", "a2"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "name": "Find numbers modulo a base", "functions": {}, "showQuestionGroupNames": false, "parts": [{"prompt": "
Find the following numbers modulo the given number $n$.
", "tags": ["Arithmetic", "arithmetic", "checked2015", "MAS2213", "mod", "Modular arithmetic", "modular arithmetic", "modulo", "remainder algorithm for integers", "tested1"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "11/07/2012:
\n
Added tags.
Calculation checked.
\n24/07/2012:
\nAdded description.
\n3/08/2012:
\nIn the Advice section, moved \\Rightarrow to the beginning of the line instead of the end of the previous line.
\nQuestion appears to be working correctly.
\n20/12/2012:
\nChanged marks from 0.5 for each part to 1 for each part.
\nCould replace the variables using the mod function which is available, also use except for the random variable values. But not for now, calculations checked.
\nAdded tag tested1.
", "licence": "Creative Commons Attribution 4.0 International", "description": "Modular arithmetic. Find the following numbers modulo the given number $n$. Three examples to do.
"}, "variablesTest": {"condition": "", "maxRuns": 100}, "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}$
", "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}]}]}], "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}]}