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

Gentle intro to modular arithmetic through quotients and remainders

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

Given integers $a,b \\in \\mathbb Z$ we can write $a$ in the form

\n

$ a = qb + r$

\n

for some $q,r \\in \\mathbb Z$ where $0 \\leq r < b$. The numbers $q$ and $r$ are called the quotient and remainder when $a$ is divided by $b$:

\n

$\\displaystyle \\frac{a}{b} = q + \\frac{r}{b}$.

\n

In modular arithmetic (in this case, modulo $b$) our interest is focused on the remainder. The operation $a \\operatorname{mod} b = r$.

", "advice": "

The first two questions introduce the idea that different numbers in $\\mathbb Z$ can be the same in modulo $b$. For example in modulo $\\var{p}$ the numbers

\n

$\\var{p}, \\var{2p}, \\var{3p}, \\cdots$

\n

are equivalent to zero. While the numbers

\n

$\\var{p2+1}, \\var{2p2+1}, \\var{3p2+1}, \\cdots$

\n

are equivalent to $1 \\pmod{\\var{p2}}$.

\n
\n

The next question introduce a simple divisibility test: $a=qb = qb+0$ exactly when $a\\equiv 0\\pmod{b}$. This is just another way to say that $b$ divides $a$, or that $a$ is a multiple of $b$. In particular

\n

$\\var{p*p2} = \\var{p}\\times \\var{p2}$ is divisible by $\\var{p}$ and $\\var{p2}$.

", "rulesets": {}, "extensions": [], "variables": {"p2": {"name": "p2", "group": "Ungrouped variables", "definition": "random(4..9 except p)", "description": "", "templateType": "anything"}, "p": {"name": "p", "group": "Ungrouped variables", "definition": "random(4..9)", "description": "", "templateType": "anything"}, "r": {"name": "r", "group": "Ungrouped variables", "definition": "random(1..(p-2))", "description": "", "templateType": "anything"}, "r2": {"name": "r2", "group": "Ungrouped variables", "definition": "random(1..(p2-2) except r)", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["p", "r", "p2", "r2"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "m_n_2", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Which numbers have a remainder of $\\var{r}$ when divided by $\\var{p}$? These numbers would be considered equal in modulo $\\var{p}$.

", "minMarks": 0, "maxMarks": "1", "shuffleChoices": true, "displayType": "checkbox", "displayColumns": 0, "minAnswers": 0, "maxAnswers": 0, "warningType": "none", "showCellAnswerState": true, "choices": ["

$\\var{r+p}$

", "

$\\var{r-p}$

", "

$\\var{r+p+1}$

", "

$\\var{r-p-1}$

", "

$\\var{r-2p+1}$

", "

$\\var{r-2p}$

", "

$\\var{r+3p}$

"], "matrix": ["0.25", "0.25", "-0.25", "-0.25", "-0.25", "0.25", "0.25"], "distractors": ["$\\var{r+p} = 1\\times \\var{p} + \\var{r}$ and so has remainder $\\var{r}$.", "$\\var{r-p} = (-1)\\times \\var{p} + \\var{r}$ and so has remainder $\\var{r}$.", "$\\var{r+p+1} = 1\\times \\var{p} + \\var{r+1}$ and so has remainder $\\var{r+1}$.", "$\\var{r-p-1} = (-1)\\times \\var{p} + \\var{r-1}$ and so has remainder $\\var{r-1}$.", "$\\var{r-2p-1} = (-2)\\times \\var{p} + \\var{r-1}$ and so has remainder $\\var{r-1}$.", "$\\var{r-2p} = (-2)\\times \\var{p} + \\var{r}$ and so has remainder $\\var{r}$.", "$\\var{r+3p} = 3\\times \\var{p} + \\var{r}$ and so has remainder $\\var{r}$."]}, {"type": "m_n_2", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Which numbers are equal to $\\var{r2}$ in modulo $\\var{p2}$?

", "minMarks": 0, "maxMarks": "1", "shuffleChoices": true, "displayType": "checkbox", "displayColumns": 0, "minAnswers": 0, "maxAnswers": 0, "warningType": "none", "showCellAnswerState": true, "choices": ["

$\\var{r2+p2}$

", "

$\\var{r2-p2}$

", "

$\\var{r2+p2+1}$

", "

$\\var{r2-p2-1}$

", "

$\\var{r2}$

", "

$\\var{r2-2*p2}$

", "

$\\var{r2+3*p2-1}$

"], "matrix": ["0.25", "0.25", "-0.25", "-0.25", "0.25", "0.25", "-0.25"], "distractors": ["$\\var{r2+p2} = 1\\times \\var{p2} + \\var{r2}$ and so has remainder $\\var{r2}$.", "$\\var{r2-p2} = (-1)\\times \\var{p2} + \\var{r2}$ and so has remainder $\\var{r2}$.", "$\\var{r2+p2+1} = 1\\times \\var{p2} + \\var{r2+1}$ and so has remainder $\\var{r2+1}$.", "$\\var{r2-p2-1} = (-1)\\times \\var{p2} + \\var{r2-1}$ and so has remainder $\\var{r2-1}$.", "$\\var{r2} = (0)\\times \\var{p2} + \\var{r2}$ and so has remainder $\\var{r2}$.", "$\\var{r2-2*p2} = (-2)\\times \\var{p2} + \\var{r2}$ and so has remainder $\\var{r2}$.", "$\\var{r2+3*p2-1} = 3\\times \\var{p2} + \\var{r2-1}$ and so has remainder $\\var{r2-1}$."]}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {"mark": {"script": "// extract question variables\nvar variables = this.question.scope.variables;\nvar unwrap = Numbas.jme.unwrapValue;\nvar p1 = unwrap(variables.p);\nvar p2 = unwrap(variables.p2);\n\ntry {\n // get the student's answers to the first two steps\n var ans = Numbas.util.parseNumber(this.studentAnswer);\n \n var grade = 0;\n \n if (ans == 0) {\n this.markingComment(\"The question asks for a non-zero number.\");\n }\n else {\n var p = p1;\n for (var i = 0; i < 2; i++) \n { \n if (0 == (ans % p)) {\n grade += 0.5;\n this.markingComment(\"$\" + ans + \" = \" + (ans % p) + \" \\\\pmod{\" + p + \"}$.\");\n } \n else {\n this.markingComment(\"$\" + ans + \" = \" + (ans % p) + \" \\\\neq 0 \\\\pmod{\" + p + \"}$.\");\n };\n p = p2;\n }\n }\n this.setCredit(grade,\"\");\n //var ans = unwrap(Numbas.jme.evaluate(tree,this.question.scope));\n \n}\ncatch(e) {\n this.markingComment(e);\n}", "order": "instead"}, "validate": {"script": "return Numbas.util.isNumber(this.studentAnswer,false,\"\");", "order": "instead"}}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

A number $a$ is a multiple of $b$ precisely when $a=qb$ for some number $q$. In terms of modular arithmetic we would say $a \\operatorname{mod} b = 0$ because $a$ has no remainder when divided by $b$.

\n

Enter a non-zero number which is equivalent to $0 \\pmod{\\var{p}}$ and also equivalent to $0 \\pmod{\\var{p2}}$.

", "minValue": "{p*p2}", "maxValue": "{p*p2}", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}, {"name": "Sean Gardiner", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2443/"}]}]}], "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}, {"name": "Sean Gardiner", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2443/"}]}