// Numbas version: exam_results_page_options {"name": "Copy of 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": [{"functions": {}, "preamble": {"css": "", "js": ""}, "variablesTest": {"condition": "", "maxRuns": 100}, "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 < p$. The numbers $q$ and $r$ correspond to the quotient and remainder when $a$ is divided by $b$:

\n

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

\n

In this topic we fix an integer $b$ and consider only the remainders of a number, this is called modular arithmetic or $\\mod(b)$.

", "name": "Copy of Modular Arithmetic: quotient and remainder", "rulesets": {}, "ungrouped_variables": ["p", "r", "p2", "r2"], "tags": [], "metadata": {"licence": "Creative Commons Attribution-ShareAlike 4.0 International", "description": "

Gentle intro to modular arithmetic through quotients and remainders

"}, "parts": [{"shuffleChoices": true, "displayColumns": 0, "type": "m_n_2", "customMarkingAlgorithm": "", "maxAnswers": 0, "marks": 0, "showCorrectAnswer": true, "displayType": "checkbox", "extendBaseMarkingAlgorithm": true, "maxMarks": "1", "unitTests": [], "variableReplacements": [], "prompt": "

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

", "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"], "scripts": {}, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "minMarks": 0, "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}$."], "warningType": "none", "minAnswers": 0}, {"shuffleChoices": true, "displayColumns": 0, "type": "m_n_2", "customMarkingAlgorithm": "", "maxAnswers": 0, "marks": 0, "showCorrectAnswer": true, "displayType": "checkbox", "extendBaseMarkingAlgorithm": true, "maxMarks": "1", "unitTests": [], "variableReplacements": [], "prompt": "

Which numbers are equal to $\\var{r2}$ in $\\mod(\\var{p2})$?

", "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"], "scripts": {}, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "minMarks": 0, "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}$."], "warningType": "none", "minAnswers": 0}, {"scripts": {"validate": {"order": "instead", "script": "return Numbas.util.isNumber(this.studentAnswer,false,\"\");"}, "mark": {"order": "instead", "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 p = p1;\n var grade = 0;\n for (var i = 0; i < 2; i++) \n {\n if (0 == (ans % p)) {\n grade += 0.5;\n this.markingComment(\"$\" + ans + \" = \" + (ans % p) + \" \\\\mod(\" + p + \")$.\");\n } else {\n this.markingComment(\"$\" + ans + \" = \" + (ans % p) + \" \\\\neq 0 \\\\mod(\" + p + \")$.\");\n }\n p = p2;\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}"}}, "maxValue": "{p*p2}", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showFeedbackIcon": true, "type": "numberentry", "allowFractions": false, "customMarkingAlgorithm": "", "marks": 1, "showCorrectAnswer": true, "correctAnswerStyle": "plain", "extendBaseMarkingAlgorithm": true, "mustBeReducedPC": 0, "unitTests": [], "variableReplacements": [], "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 this as $a = 0 \\mod(b)$ because $a$ has no remainder when divided by $b$.

\n

Enter a non-zero number which is equal to $0 \\mod(\\var{p})$ and also equal to $0 \\mod(\\var{p2})$.

", "notationStyles": ["plain", "en", "si-en"], "minValue": "{p*p2}", "mustBeReduced": false}], "variable_groups": [], "advice": "

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

\n

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

\n

are all equal to zero. While the numbers

\n

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

\n

are all equal to $1 \\mod(\\var{p2})$.

\n
\n

The next question introduce a simple divisibility test: $a=qb = qb+0$ exactly when $a=0\\mod(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}$.

", "extensions": [], "variables": {"p": {"definition": "random(4..9)", "name": "p", "templateType": "anything", "group": "Ungrouped variables", "description": ""}, "r": {"definition": "random(1..(p-2))", "name": "r", "templateType": "anything", "group": "Ungrouped variables", "description": ""}, "r2": {"definition": "random(1..(p2-2) except r)", "name": "r2", "templateType": "anything", "group": "Ungrouped variables", "description": ""}, "p2": {"definition": "random(3..9 except p)", "name": "p2", "templateType": "anything", "group": "Ungrouped variables", "description": ""}}, "type": "question", "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}, {"name": "Paul Emanuel", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2551/"}]}]}], "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}, {"name": "Paul Emanuel", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2551/"}]}