// 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": "
    \n
  1. $\\var{a} \\bmod \\var{n}=$ [[0]]
    Input your answer as an integer $a$, $0 \\le a \\le \\var{n-1}$.
  2. \n
  3. $\\var{a1} \\bmod \\var{n1}=$ [[1]]
    Input your answer as an integer $b$, $0 \\le b \\le \\var{n1-1}$.
  4. \n
  5. $\\var{a2} \\bmod \\var{n2}=$ [[2]]
    Input your answer as an integer $c$, $0 \\le c \\le \\var{n2-1}$.
  6. \n
", "scripts": {}, "gaps": [{"correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "allowFractions": false, "type": "numberentry", "maxValue": "{r}", "minValue": "{r}", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1, "showPrecisionHint": false}, {"correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "allowFractions": false, "type": "numberentry", "maxValue": "{r1}", "minValue": "{r1}", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1, "showPrecisionHint": false}, {"correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "allowFractions": false, "type": "numberentry", "maxValue": "{r2}", "minValue": "{r2}", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1, "showPrecisionHint": false}], "type": "gapfill", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 0}], "statement": "

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.

\n

Calculation checked.

\n

24/07/2012:

\n

Added description.

\n

3/08/2012:

\n

In the Advice section, moved \\Rightarrow to the beginning of the line instead of the end of the previous line.

\n

Question appears to be working correctly.

\n

20/12/2012:

\n

Changed marks from 0.5 for each part to 1 for each part.

\n

Could replace the variables using the mod function which is available, also use except for the random variable values. But not for now, calculations checked.

\n

Added 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": "

a)

\n

We seek a number

\n

\\[r=\\var{a} \\bmod \\var{n} \\implies \\var{a} = m\\var{n}+r \\]

\n

where $m$ is a positive integer and $0 \\le r \\le \\var{n-1}$.

\n

This 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}

\n

on multiplying through by $\\var{n}$.

\n

Hence $r=\\var{r}$ and $\\var{a} \\bmod \\var{n}=\\var{r}$.

\n

You can use your calculator to find this as follows:

\n

Divide $\\var{a}$ by $\\var{n}$ to get

\n

\\[ \\frac{\\var{a}}{\\var{n}}=\\var{a/n}=\\var{m}+\\var{a/n-m} \\]

\n

Then multiplying $\\var{a/n-m}$ by $\\var{n}$ gives the remainder, i.e.

\n

\\[ \\var{a/n-m}\\times \\var{n} = \\var{r} \\]

\n

This 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.

\n

b)

\n

As in a),

\n

\\[\\frac{\\var{a1}}{\\var{n1}}=\\var{m1}+\\frac{\\var{r1}}{\\var{n1}}\\]

\n

So $\\var{a1} \\bmod \\var{n1} = \\var{r1}$

\n

c)

\n

\\[\\frac{\\var{a2}}{\\var{n2}}=\\var{m2}+\\frac{\\var{r2}}{\\var{n2}}\\]

\n

So $\\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/"}]}