// Numbas version: finer_feedback_settings {"name": "Blathnaid's copy of Number theory and cryptography", "feedback": {"allowrevealanswer": true, "showtotalmark": true, "advicethreshold": 0, "intro": "", "feedbackmessages": [], "showanswerstate": true, "showactualmark": true, "enterreviewmodeimmediately": true, "showexpectedanswerswhen": "inreview", "showpartfeedbackmessageswhen": "always", "showactualmarkwhen": "always", "showtotalmarkwhen": "always", "showanswerstatewhen": "always", "showadvicewhen": "never"}, "timing": {"allowPause": true, "timeout": {"action": "none", "message": ""}, "timedwarning": {"action": "none", "message": ""}}, "allQuestions": true, "shuffleQuestions": false, "percentPass": 0, "duration": 0, "pickQuestions": 0, "navigation": {"onleave": {"action": "none", "message": ""}, "reverse": true, "allowregen": true, "showresultspage": "oncompletion", "preventleave": true, "browse": true, "showfrontpage": true}, "metadata": {"description": "Questions used in a university course titled \"Number theory and cryptography\"", "licence": "Creative Commons Attribution 4.0 International"}, "type": "exam", "questions": [], "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": [{"name": "Factorise four numbers", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "parts": [{"customName": "", "customMarkingAlgorithm": "", "showCorrectAnswer": true, "useCustomName": false, "prompt": "

$\\var{numbers[0]} =$ [[0]]

", "unitTests": [], "showFeedbackIcon": true, "scripts": {}, "gaps": [{"answer": "{numbers[0]}", "showCorrectAnswer": true, "customMarkingAlgorithm": "", "checkingType": "absdiff", "vsetRangePoints": 5, "failureRate": 1, "customName": "", "checkVariableNames": false, "unitTests": [], "valuegenerators": [], "vsetRange": [0, 1], "showFeedbackIcon": true, "scripts": {"constructor": {"script": "question.createFactorisePart(this);", "order": "after"}, "mark": {"script": "question.markFactorisePart(this);", "order": "instead"}}, "extendBaseMarkingAlgorithm": true, "type": "jme", "variableReplacementStrategy": "originalfirst", "useCustomName": false, "checkingAccuracy": 0.001, "showPreview": true, "variableReplacements": [], "marks": "0.25"}], "type": "gapfill", "extendBaseMarkingAlgorithm": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 0, "sortAnswers": false}, {"customName": "", "customMarkingAlgorithm": "", "showCorrectAnswer": true, "useCustomName": false, "prompt": "

$\\var{numbers[1]} =$ [[0]]

", "unitTests": [], "showFeedbackIcon": true, "scripts": {}, "gaps": [{"answer": "{numbers[1]}", "showCorrectAnswer": true, "customMarkingAlgorithm": "", "checkingType": "absdiff", "vsetRangePoints": 5, "failureRate": 1, "customName": "", "checkVariableNames": false, "unitTests": [], "valuegenerators": [], "vsetRange": [0, 1], "showFeedbackIcon": true, "scripts": {"constructor": {"script": "question.createFactorisePart(this);", "order": "after"}, "mark": {"script": "question.markFactorisePart(this);", "order": "instead"}}, "extendBaseMarkingAlgorithm": true, "type": "jme", "variableReplacementStrategy": "originalfirst", "useCustomName": false, "checkingAccuracy": 0.001, "showPreview": true, "variableReplacements": [], "marks": "0.25"}], "type": "gapfill", "extendBaseMarkingAlgorithm": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 0, "sortAnswers": false}, {"customName": "", "customMarkingAlgorithm": "", "showCorrectAnswer": true, "useCustomName": false, "prompt": "

$\\var{numbers[2]} =$ [[0]]

", "unitTests": [], "showFeedbackIcon": true, "scripts": {}, "gaps": [{"answer": "{numbers[2]}", "showCorrectAnswer": true, "customMarkingAlgorithm": "", "checkingType": "absdiff", "vsetRangePoints": 5, "failureRate": 1, "customName": "", "checkVariableNames": false, "unitTests": [], "valuegenerators": [], "vsetRange": [0, 1], "showFeedbackIcon": true, "scripts": {"constructor": {"script": "question.createFactorisePart(this);", "order": "after"}, "mark": {"script": "question.markFactorisePart(this);", "order": "instead"}}, "extendBaseMarkingAlgorithm": true, "type": "jme", "variableReplacementStrategy": "originalfirst", "useCustomName": false, "checkingAccuracy": 0.001, "showPreview": true, "variableReplacements": [], "marks": "0.25"}], "type": "gapfill", "extendBaseMarkingAlgorithm": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 0, "sortAnswers": false}, {"customName": "", "customMarkingAlgorithm": "", "showCorrectAnswer": true, "useCustomName": false, "prompt": "

$\\var{numbers[3]} =$ [[0]]

", "unitTests": [], "showFeedbackIcon": true, "scripts": {}, "gaps": [{"answer": "{numbers[3]}", "showCorrectAnswer": true, "customMarkingAlgorithm": "", "checkingType": "absdiff", "vsetRangePoints": 5, "failureRate": 1, "customName": "", "checkVariableNames": false, "unitTests": [], "valuegenerators": [], "vsetRange": [0, 1], "showFeedbackIcon": true, "scripts": {"constructor": {"script": "question.createFactorisePart(this);", "order": "after"}, "mark": {"script": "question.markFactorisePart(this);", "order": "instead"}}, "extendBaseMarkingAlgorithm": true, "type": "jme", "variableReplacementStrategy": "originalfirst", "useCustomName": false, "checkingAccuracy": 0.001, "showPreview": true, "variableReplacements": [], "marks": "0.25"}], "type": "gapfill", "extendBaseMarkingAlgorithm": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 0, "sortAnswers": false}], "variables": {"numbers": {"group": "Ungrouped variables", "templateType": "anything", "definition": "shuffle(list(1900..2015))[0..4]", "description": "", "name": "numbers"}}, "ungrouped_variables": ["numbers"], "functions": {"list": {"type": "number", "language": "javascript", "definition": "return r.slice(3);", "parameters": [["r", "range"]]}}, "variable_groups": [], "preamble": {"css": "", "js": "question.createFactorisePart = function(p) {\n var n = parseInt(p.settings.correctAnswer);\n var factors = Numbas.math.factorise(n);\n\n p.settings.correctAnswer = p.display.correctAnswer = factors.map(function(pow,i){\n if(pow==1) {\n return Numbas.math.primes[i];\n } else if(pow>0){\n return Numbas.math.primes[i]+'^'+pow;\n } else {\n return '';\n }\n }).filter(function(x){return x}).join(' * ');\n\n p.display.correctAnswerLaTeX = factors.map(function(pow,i){\n if(pow==1) {\n return Numbas.math.primes[i];\n } else if(pow>0){\n return Numbas.math.primes[i]+'^{'+pow+'}';\n } else {\n return '';\n }\n }).filter(function(x){return x}).join(' \\\\times ');\n}\n\nquestion.markFactorisePart = function(p) {\n var m = Numbas.jme.display.matchExpression('m_all(m_any(m_number,m_number^m_number));factors*??',p.studentAnswer,true);\n\n function onlyPrimes(tree) {\n var number;\n if(tree.tok.type=='op' && tree.tok.name=='*') {\n return onlyPrimes(tree.args[0]) && onlyPrimes(tree.args[1]);\n } else if(tree.tok.type=='op' && tree.tok.name=='^') {\n number = tree.args[0].tok.value;\n } else {\n number = tree.tok.value;\n }\n return Numbas.math.primes.contains(number);\n }\n\n if(!onlyPrimes(m.factors)) {\n p.setCredit(0,'Your answer is not completely factorised.');\n return ;\n }\n Numbas.parts.JMEPart.prototype.mark.apply(p);\n}"}, "variablesTest": {"condition": "", "maxRuns": 100}, "statement": "

Factorize completely the following numbers.

\n

For example if you are factorizing $1998$ then we have $1998 = 2 \\times 3^3 \\times 37$ and you would enter 2 * 3^3 * 37.

", "tags": ["checked2015"], "rulesets": {}, "type": "question", "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

Pick four numbers from $1900\\dots 2015$ and ask the student to factorise them.

\n

Custom marking scripts make sure the student has entered a complete factorisation.

"}, "advice": ""}, {"name": "Factorise numbers into products of prime powers", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"e2": {"group": "Ungrouped variables", "templateType": "anything", "definition": "if(e1>1,0,2)", "description": "", "name": "e2"}, "lgp": {"group": "Ungrouped variables", "templateType": "anything", "definition": "[59,61,67,73,79]", "description": "", "name": "lgp"}, "e1": {"group": "Ungrouped variables", "templateType": "anything", "definition": "random(2,3)", "description": "", "name": "e1"}, "p1": {"group": "Ungrouped variables", "templateType": "anything", "definition": "random(sgp)", "description": "", "name": "p1"}, "e3": {"group": "Ungrouped variables", "templateType": "anything", "definition": "1", "description": "", "name": "e3"}, "p3": {"group": "Ungrouped variables", "templateType": "anything", "definition": "random(mgp)", "description": "", "name": "p3"}, "e5": {"group": "Ungrouped variables", "templateType": "anything", "definition": "1", "description": "", "name": "e5"}, "p5": {"group": "Ungrouped variables", "templateType": "anything", "definition": "random(lgp)", "description": "", "name": "p5"}, "sgp": {"group": "Ungrouped variables", "templateType": "anything", "definition": "[2,2,2,3,3,3,5,5,5,7,7,7,11,11,13]", "description": "", "name": "sgp"}, "p2": {"group": "Ungrouped variables", "templateType": "anything", "definition": "random(sgp)", "description": "", "name": "p2"}, "mgp": {"group": "Ungrouped variables", "templateType": "anything", "definition": "[17,19,23,29,31,37,41,43,47]", "description": "", "name": "mgp"}, "ntbf": {"group": "Ungrouped variables", "templateType": "anything", "definition": "p1^e1 * p2^e2 * p3^e3 * p5^e5", "description": "", "name": "ntbf"}}, "ungrouped_variables": ["p2", "p3", "p1", "p5", "sgp", "ntbf", "mgp", "e5", "lgp", "e1", "e3", "e2"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "showQuestionGroupNames": false, "functions": {}, "parts": [{"scripts": {}, "gaps": [{"answer": "{p1^e1*p2^e2*p3^e3*p5^e5}", "musthave": {"message": "

Split into factors, each factor a power of a prime number and include the multiplication sign * between the factors

", "showStrings": false, "partialCredit": 0, "strings": ["*", "^"]}, "vsetrange": [0, 1], "scripts": {"constructor": {"script": "question.createFactorisePart(this);", "order": "after"}, "mark": {"script": "question.markFactorisePart(this);", "order": "instead"}}, "answersimplification": "unitPower,zeroPower,unitFactor", "expectedvariablenames": [], "showpreview": true, "checkingtype": "absdiff", "checkingaccuracy": 0.001, "minlength": {"length": 7, "message": "", "partialCredit": 0}, "type": "jme", "checkvariablenames": false, "showCorrectAnswer": true, "marks": 3, "vsetrangepoints": 5}], "type": "gapfill", "prompt": "\n\n\n

Factorize completely $\\var{ntbf}$.

\n\n\n\n

Input your answer in the form p^r * q^s * ... where $p, q, \\dots$ are distinct primes and $r, s, \\dots$ are their powers.

\n\n\n\n

$\\var{ntbf}=\\;\\;$[[0]]

\n\n\n\n

(There is a Maple function $\\mathrm{ifactor}(n)$ which factorizes integers.)

\n\n", "showCorrectAnswer": true, "marks": 0}], "variablesTest": {"condition": "", "maxRuns": 100}, "statement": "", "tags": ["Arithmetic", "arithmetic", "checked2015", "factorisation", "factorization", "integers", "MAS3214", "number theory", "prime factorisation", "prime factorization", "prime factors", "prime numbers", "prime powers"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": "question.createFactorisePart = function(p) {\n var n = parseInt(p.settings.correctAnswer);\n var factors = Numbas.math.factorise(n);\n\n p.settings.correctAnswer = p.display.correctAnswer = factors.map(function(pow,i){\n if(pow==1) {\n return Numbas.math.primes[i];\n } else if(pow>0){\n return Numbas.math.primes[i]+'^'+pow;\n } else {\n return '';\n }\n }).filter(function(x){return x}).join(' * ');\n\n p.display.correctAnswerLaTeX = factors.map(function(pow,i){\n if(pow==1) {\n return Numbas.math.primes[i];\n } else if(pow>0){\n return Numbas.math.primes[i]+'^{'+pow+'}';\n } else {\n return '';\n }\n }).filter(function(x){return x}).join(' \\\\times ');\n}\n\nquestion.markFactorisePart = function(p) {\n var m = Numbas.jme.display.matchExpression('m_all(m_any(m_number,m_number^m_number));factors*??',p.studentAnswer,true);\n\n function onlyPrimes(tree) {\n var number;\n if(tree.tok.type=='op' && tree.tok.name=='*') {\n return onlyPrimes(tree.args[0]) && onlyPrimes(tree.args[1]);\n } else if(tree.tok.type=='op' && tree.tok.name=='^') {\n number = tree.args[0].tok.value;\n } else {\n number = tree.tok.value;\n }\n return Numbas.math.primes.contains(number);\n }\n\n if(!onlyPrimes(m.factors)) {\n p.setCredit(0,'Your answer is not completely factorised.');\n return ;\n }\n JMEPart.prototype.mark.apply(p);\n}"}, "type": "question", "metadata": {"notes": "

16/08/2012:

\n

Added tags.

\n

Added description.

\n

No advice given.

", "licence": "Creative Commons Attribution 4.0 International", "description": "

Factorising 5 to 7 digit numbers into a product of prime powers.

\n

Uses the marking algorithms from question 1 of this CBA

"}, "advice": "\n\n\n\n\n"}, {"name": "Blathnaid's copy of Perform arithmetic in Z_n", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Blathnaid Sheridan", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/447/"}], "functions": {}, "ungrouped_variables": ["a1", "g5", "ans3", "g3", "ans1", "ans2", "t5", "ans4", "ans5", "s5", "h5", "b4", "b5", "a3", "a2", "a5", "b1", "b2", "b3", "a4"], "tags": ["checked2015", "MAS3214", "Modular arithmetic", "modular arithmetic"], "advice": "

In the the last part, working out $(\\var{a5}+\\var{b5})\\times (\\var{g5}+\\var{h5}) \\bmod{X}$, it is sometimes easier to work out $(\\var{a5}+\\var{b5}) \\bmod{X}$ and $(\\var{g5}+\\var{h5}) \\bmod{X}$ separately, giving two numbers in the range $[0 \\dots X-1]$, and then to multiply them together.

\n

For example, working $\\bmod{9}$ we have:

\n

\\begin{align}
\\var{a5}+\\var{b5}&\\equiv \\var{mod(a5+b5,9)} \\bmod{9}, \\\\
\\var{g5}+\\var{h5}&\\equiv \\var{mod(g5+h5,9)} \\bmod{9}. \\\\ \\\\
(\\var{a5}+\\var{b5})\\times (\\var{g5}+\\var{h5}) &\\equiv \\var{s5} \\times \\var{t5} \\bmod{9} \\\\
&\\equiv \\var{mod(ans5,9)} \\bmod{9}
\\end{align}

", "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "parts": [{"prompt": "\n \n \n

Perform the following calculations in $\\mathbb{Z}_{2},\\;\\;\\mathbb{Z}_{9},\\;\\;\\mathbb{Z}_{10}$.

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
$\\mathbb{Z}_{2}$$\\mathbb{Z}_{9}$$\\mathbb{Z}_{10}$
$\\var{a1}+\\var{b1}$[[0]][[1]][[2]]
$\\var{a2}\\times\\var{b2}$[[3]][[4]][[5]]
$\\var{a3}\\times(\\var{b3}+\\var{g3})$[[6]][[7]][[8]]
$\\var{a4}\\times\\var{b4}$[[9]][[10]][[11]]
$(\\var{a5}+\\var{b5})\\times (\\var{g5}+\\var{h5})$[[12]][[13]][[14]]
\n \n ", "marks": 0, "gaps": [{"allowFractions": false, "scripts": {}, "maxValue": "{mod(ans1,2)}", "minValue": "{mod(ans1,2)}", "correctAnswerFraction": false, "showCorrectAnswer": true, "marks": 0.2, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "scripts": {}, "maxValue": "{mod(ans1,9)}", "minValue": "{mod(ans1,9)}", "correctAnswerFraction": false, "showCorrectAnswer": true, "marks": 0.2, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "scripts": {}, "maxValue": "{mod(ans1,10)}", "minValue": "{mod(ans1,10)}", "correctAnswerFraction": false, "showCorrectAnswer": true, "marks": 0.2, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "scripts": {}, "maxValue": "{mod(ans2,2)}", "minValue": "{mod(ans2,2)}", "correctAnswerFraction": false, "showCorrectAnswer": true, "marks": 0.2, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "scripts": {}, "maxValue": "{mod(ans2,9)}", "minValue": "{mod(ans2,9)}", "correctAnswerFraction": false, "showCorrectAnswer": true, "marks": 0.2, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "scripts": {}, "maxValue": "{mod(ans2,10)}", "minValue": "{mod(ans2,10)}", "correctAnswerFraction": false, "showCorrectAnswer": true, "marks": 0.2, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "scripts": {}, "maxValue": "{mod(ans3,2)}", "minValue": "{mod(ans3,2)}", "correctAnswerFraction": false, "showCorrectAnswer": true, "marks": 0.2, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "scripts": {}, "maxValue": "{mod(ans3,9)}", "minValue": "{mod(ans3,9)}", "correctAnswerFraction": false, "showCorrectAnswer": true, "marks": 0.2, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "scripts": {}, "maxValue": "{mod(ans3,10)}", "minValue": "{mod(ans3,10)}", "correctAnswerFraction": false, "showCorrectAnswer": true, "marks": 0.2, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "scripts": {}, "maxValue": "{mod(ans4,2)}", "minValue": "{mod(ans4,2)}", "correctAnswerFraction": false, "showCorrectAnswer": true, "marks": 0.2, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "scripts": {}, "maxValue": "{mod(ans4,9)}", "minValue": "{mod(ans4,9)}", "correctAnswerFraction": false, "showCorrectAnswer": true, "marks": 0.2, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "scripts": {}, "maxValue": "{mod(ans4,10)}", "minValue": "{mod(ans4,10)}", "correctAnswerFraction": false, "showCorrectAnswer": true, "marks": 0.2, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "scripts": {}, "maxValue": "{mod(ans5,2)}", "minValue": "{mod(ans5,2)}", "correctAnswerFraction": false, "showCorrectAnswer": true, "marks": 0.2, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "scripts": {}, "maxValue": "{mod(ans5,9)}", "minValue": "{mod(ans5,9)}", "correctAnswerFraction": false, "showCorrectAnswer": true, "marks": 0.2, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "scripts": {}, "maxValue": "{mod(ans5,10)}", "minValue": "{mod(ans5,10)}", "correctAnswerFraction": false, "showCorrectAnswer": true, "marks": 0.2, "type": "numberentry", "showPrecisionHint": false}], "showCorrectAnswer": true, "scripts": {}, "type": "gapfill"}], "statement": "", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "preamble": {"css": "", "js": ""}, "variables": {"a1": {"definition": "random(1..4)", "templateType": "anything", "group": "Ungrouped variables", "name": "a1", "description": ""}, "g5": {"definition": "random(5..9)", "templateType": "anything", "group": "Ungrouped variables", "name": "g5", "description": ""}, "ans3": {"definition": "a3*(b3+g3)", "templateType": "anything", "group": "Ungrouped variables", "name": "ans3", "description": ""}, "g3": {"definition": "random(3..6)", "templateType": "anything", "group": "Ungrouped variables", "name": "g3", "description": ""}, "ans1": {"definition": "a1+b1", "templateType": "anything", "group": "Ungrouped variables", "name": "ans1", "description": ""}, "ans2": {"definition": "a2*b2", "templateType": "anything", "group": "Ungrouped variables", "name": "ans2", "description": ""}, "t5": {"definition": "mod(g5+h5,9)", "templateType": "anything", "group": "Ungrouped variables", "name": "t5", "description": ""}, "ans4": {"definition": "a4*b4", "templateType": "anything", "group": "Ungrouped variables", "name": "ans4", "description": ""}, "ans5": {"definition": "(a5+b5)*(g5+h5)", "templateType": "anything", "group": "Ungrouped variables", "name": "ans5", "description": ""}, "s5": {"definition": "mod(a5+b5,9)", "templateType": "anything", "group": "Ungrouped variables", "name": "s5", "description": ""}, "h5": {"definition": "random(5..9)", "templateType": "anything", "group": "Ungrouped variables", "name": "h5", "description": ""}, "b4": {"definition": "random(6..9)", "templateType": "anything", "group": "Ungrouped variables", "name": "b4", "description": ""}, "b5": {"definition": "random(5..9)", "templateType": "anything", "group": "Ungrouped variables", "name": "b5", "description": ""}, "a3": {"definition": "random(3..6)", "templateType": "anything", "group": "Ungrouped variables", "name": "a3", "description": ""}, "a2": {"definition": "random(2..5)", "templateType": "anything", "group": "Ungrouped variables", "name": "a2", "description": ""}, "a5": {"definition": "random(5..9)", "templateType": "anything", "group": "Ungrouped variables", "name": "a5", "description": ""}, "b1": {"definition": "random(2..4)", "templateType": "anything", "group": "Ungrouped variables", "name": "b1", "description": ""}, "b2": {"definition": "random(2..5)", "templateType": "anything", "group": "Ungrouped variables", "name": "b2", "description": ""}, "b3": {"definition": "random(3..6)", "templateType": "anything", "group": "Ungrouped variables", "name": "b3", "description": ""}, "a4": {"definition": "random(6..9)", "templateType": "anything", "group": "Ungrouped variables", "name": "a4", "description": ""}}, "metadata": {"notes": "

16/08/2012:

\n


Added tags.

\n

Added description.    

", "description": "

Calculations in $\\mathbb{Z_n}$ for three values of $n$.     

", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}]}, {"name": "Simplify integers and rationals in Z_n", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [], "variables": {"s1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1,-1)", "name": "s1", "description": ""}, "b3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2,4,8,13,16,17)", "name": "b3", "description": ""}, "ans1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "a1*b1 + c1*d1 - f1", "name": "ans1", "description": ""}, "f1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2..9)", "name": "f1", "description": ""}, "inv5": {"templateType": "anything", "group": "Ungrouped variables", "definition": "makepos(rinv5, 5)", "name": "inv5", "description": ""}, "ans13": {"templateType": "anything", "group": "Ungrouped variables", "definition": "makepos(ans1,3)", "name": "ans13", "description": ""}, "p3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "extendedgcd1(max(3,b3),min(3,b3))", "name": "p3", "description": ""}, "inv11": {"templateType": "anything", "group": "Ungrouped variables", "definition": "makepos(rinv11, 11)", "name": "inv11", "description": ""}, "s2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(s1=1,-1,1)", "name": "s2", "description": ""}, "rinv3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(b3<3,q3,p3)", "name": "rinv3", "description": ""}, "q7": {"templateType": "anything", "group": "Ungrouped variables", "definition": "extendedgcd2(max(7,b3),min(7,b3))", "name": "q7", "description": ""}, "ans15": {"templateType": "anything", "group": "Ungrouped variables", "definition": "makepos(ans1,5)", "name": "ans15", "description": ""}, "inv3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "makepos( rinv3, 3)", "name": "inv3", "description": ""}, "rinv7": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(b3<7,q7,p7)", "name": "rinv7", "description": ""}, "c3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(17,19,23,29,31,37,41,43,47)", "name": "c3", "description": ""}, "q5": {"templateType": "anything", "group": "Ungrouped variables", "definition": "extendedgcd2(max(5,b3),min(5,b3))", "name": "q5", "description": ""}, "minv3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mod(c3*inv3,3)", "name": "minv3", "description": ""}, "ans111": {"templateType": "anything", "group": "Ungrouped variables", "definition": "makepos(ans1,11)", "name": "ans111", "description": ""}, "minv7": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mod(c3*inv7,7)", "name": "minv7", "description": ""}, "ans211": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mod(a2,11)", "name": "ans211", "description": ""}, "minv5": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mod(c3*inv5,5)", "name": "minv5", "description": ""}, "ans27": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mod(a2,7)", "name": "ans27", "description": ""}, "b1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "s2*random(3..4)", "name": "b1", "description": ""}, "q11": {"templateType": "anything", "group": "Ungrouped variables", "definition": "extendedgcd2(max(11,b3),min(11,b3))", "name": "q11", "description": ""}, "ans23": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mod(a2,3)", "name": "ans23", "description": ""}, "p7": {"templateType": "anything", "group": "Ungrouped variables", "definition": "extendedgcd1(max(7,b3),min(7,b3))", "name": "p7", "description": ""}, "d1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(4..9)", "name": "d1", "description": ""}, "p5": {"templateType": "anything", "group": "Ungrouped variables", "definition": "extendedgcd1(max(5,b3),min(5,b3))", "name": "p5", "description": ""}, "p11": {"templateType": "anything", "group": "Ungrouped variables", "definition": "extendedgcd1(max(11,b3),min(11,b3))", "name": "p11", "description": ""}, "q3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "extendedgcd2(max(3,b3),min(3,b3))", "name": "q3", "description": ""}, "inv7": {"templateType": "anything", "group": "Ungrouped variables", "definition": "makepos(rinv7, 7)", "name": "inv7", "description": ""}, "c1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(4..9)", "name": "c1", "description": ""}, "rinv11": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(b3<11,q11,p11)", "name": "rinv11", "description": ""}, "rinv5": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(b3<5,q5,p5)", "name": "rinv5", "description": ""}, "ans17": {"templateType": "anything", "group": "Ungrouped variables", "definition": "makepos(ans1,7)", "name": "ans17", "description": ""}, "ans25": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mod(a2,5)", "name": "ans25", "description": ""}, "a2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97)", "name": "a2", "description": ""}, "a1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "s1*random(3..9)", "name": "a1", "description": ""}, "minv11": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mod(c3*inv11,11)", "name": "minv11", "description": ""}}, "ungrouped_variables": ["f1", "p7", "ans1", "inv11", "b1", "b3", "ans27", "ans25", "ans23", "d1", "q3", "rinv11", "q5", "ans211", "s2", "s1", "ans111", "minv11", "a1", "ans13", "a2", "q11", "ans17", "ans15", "c3", "c1", "rinv3", "rinv5", "rinv7", "p3", "q7", "p11", "inv7", "inv5", "p5", "inv3", "minv3", "minv7", "minv5"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "showQuestionGroupNames": false, "functions": {"extendedgcd1": {"type": "number", "language": "jme", "definition": "\n\n\nif((a|b) or (b|a),\n\n0\n\n,\n\nextendedgcd2(b,mod(a,b))\n\n)\n\n\n", "parameters": [["a", "number"], ["b", "number"]]}, "extendedgcd2": {"type": "number", "language": "jme", "definition": "\n\n\nif((a|b) or (b|a),\n\n1\n\n,\n\nextendedgcd1(b,mod(a,b))-(extendedgcd2(b,mod(a,b))*floor(a/b))\n\n)\n\n\n", "parameters": [["a", "number"], ["b", "number"]]}, "makepos": {"type": "number", "language": "jme", "definition": "mod(a,b)", "parameters": [["a", "number"], ["b", "number"]]}}, "parts": [{"scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "correctAnswerFraction": false, "minValue": "{ans13}", "maxValue": "{ans13}", "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "correctAnswerFraction": false, "minValue": "{ans15}", "maxValue": "{ans15}", "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "correctAnswerFraction": false, "minValue": "{ans17}", "maxValue": "{ans17}", "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "correctAnswerFraction": false, "minValue": "{ans111}", "maxValue": "{ans111}", "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "correctAnswerFraction": false, "minValue": "{ans23}", "maxValue": "{ans23}", "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "correctAnswerFraction": false, "minValue": "{ans25}", "maxValue": "{ans25}", "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "correctAnswerFraction": false, "minValue": "{ans27}", "maxValue": "{ans27}", "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "correctAnswerFraction": false, "minValue": "{ans211}", "maxValue": "{ans211}", "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "correctAnswerFraction": false, "minValue": "{inv3}", "maxValue": "{inv3}", "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "correctAnswerFraction": false, "minValue": "{inv5}", "maxValue": "{inv5}", "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "correctAnswerFraction": false, "minValue": "{inv7}", "maxValue": "{inv7}", "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "correctAnswerFraction": false, "minValue": "{inv11}", "maxValue": "{inv11}", "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "correctAnswerFraction": false, "minValue": "{minv3}", "maxValue": "{minv3}", "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "correctAnswerFraction": false, "minValue": "{minv5}", "maxValue": "{minv5}", "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "correctAnswerFraction": false, "minValue": "{minv7}", "maxValue": "{minv7}", "marks": 0.25, "showPrecisionHint": false}, {"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "type": "numberentry", "correctAnswerFraction": false, "minValue": "{minv11}", "maxValue": "{minv11}", "marks": 0.25, "showPrecisionHint": false}], "type": "gapfill", "prompt": "

 

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
 $\\mathbb{Z}_{3}$$\\mathbb{Z}_{5}$$\\mathbb{Z}_{7}$$\\mathbb{Z}_{11}$
$\\simplify[!basic]{{a1}*{b1}+{c1}*{d1}-{f1}}$[[0]][[1]][[2]][[3]]
$\\var{a2}$[[4]][[5]][[6]][[7]]
$ \\displaystyle{ \\frac{1}{\\var{b3}} } $[[8]][[9]][[10]][[11]]
$ \\displaystyle{ \\frac{\\var{c3}}{\\var{b3}} } $[[12]][[13]][[14]][[15]]
", "showCorrectAnswer": true, "marks": 0}], "variablesTest": {"condition": "", "maxRuns": 100}, "statement": "

Simplify the following in each of $\\mathbb{Z}_{3}, \\; \\mathbb{Z}_{5}, \\; \\mathbb{Z}_{7}$ and $\\mathbb{Z}_{11}$.

\n

For the last two questions, recall that for a prime $p$, $\\displaystyle{\\frac{1}{b} \\bmod{p}}$ is the unique solution to $bx \\equiv 1 \\bmod{p}$.

\n

You must input all values as positive integers; negative integers are not accepted.

", "tags": ["checked2015", "MAS3214"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "", "licence": "Creative Commons Attribution 4.0 International", "description": "

Express various integers and rationals mod $\\mathbb{Z}_3, \\;\\mathbb{Z}_5,\\;\\mathbb{Z}_7,\\;\\mathbb{Z}_{11}$

"}, "advice": "

For the first row, it may help to simplify each of the numbers modulo the number corresponding to each column, and then perform the calculation.

\n

For example,

\n

\\begin{align}
\\simplify[!basic]{{a1}*{b1}+{c1}*{d1}-{f1}} &\\equiv \\simplify[!basic]{{mod(a1,3)}*{mod(b3,3)}+{mod(c1,3)}*{mod(d1,3)}-{mod(f1,3)}}  \\mod{3} \\\\
&\\equiv \\var{ans13} \\mod{3}
\\end{align}

\n

In the second row, you just have to work out the remainder when dividing $\\var{a2}$ by each of $3$, $5$, $7$ and $11$.

\n

In the third row we have to find the inverse of $\\var{b3}$ in each of $\\mathbb{Z}_{3}$, $\\mathbb{Z}_{5}$, $\\mathbb{Z}_{7}$ and $\\mathbb{Z}_{11}$.

\n

It should be clear to you that $\\var{b3}$ is coprime to each of $3$, $5$, $7$ and $11$, hence we can find an inverse in each of $\\mathbb{Z}_{3}$, $\\mathbb{Z}_{5}$, $\\mathbb{Z}_{7}$ and $\\mathbb{Z}_{11}$.

\n

You can do this in $\\mathbb{Z}_{3}$ by finding $x$ such that $\\var{b3}x \\equiv 1 \\bmod{3}$, similarly for $5$, $7$, $11$.

\n

You can do this by trying values to find one that works; this is easy for $\\mathbb{Z}_{3}$ since there are only two cases to check, and you will find that

\n

$b = \\var{inv3}$ satisfies $\\var{inv3} \\times \\var{b3} = \\var{inv3*b3} \\equiv 1 \\bmod{3}.$

\n

Inverse in $\\mathbb{Z}_{5}$

\n

If you cannot immediately find an inverse in $\\mathbb{Z}_{5}$, you can use the Euclidean algorithm to find $a$ and $b$ such that

\n

\\[\\var{b3}b +5a = \\operatorname{gcd}(\\var{b3},5) = 1\\]

\n

as $\\var{b3}$ and $5$ are coprime.

\n

It follows that $\\var{b3}b \\equiv 1 \\bmod{5}$, and hence $b \\bmod{5}$ is the inverse of $\\var{b3}$ in $\\mathbb{Z}_{5}$.

\n

Using the Euclidean algorithm I find that

\n

\\[\\simplify[!basic]{ {max(5,b3)}*{p5} + {min(5,b3)}*{q5} = 1 }.\\]

\n

Hence the inverse is

\n

\\[ b = \\var{rinv5} \\equiv \\var{inv5} \\bmod{5}.\\]

\n

Inverse in $\\mathbb{Z}_{7}$

\n

Once again if you cannot spot the solution:

\n

Using the Euclidean algorithm I find that

\n

\\[\\simplify[!basic]{ {max(7,b3)}*{p7} + {min(7,b3)}*{q7} = 1 }.\\]

\n

Hence the inverse of $\\var{b3}$ in $\\mathbb{Z}_{7}$ is

\n

\\[b = \\var{rinv7} \\equiv \\var{inv7} \\bmod{7}.\\]

\n

Inverse in $\\mathbb{Z}_{11}$

\n

Using the Euclidean algorithm I find that

\n

\\[\\simplify[!basic]{ {max(11,b3)}*{p11} + {min(11,b3)}*{q11} = 1}. \\]

\n

Hence the inverse of $\\var{b3}$ in $\\mathbb{Z}_{11}$ is

\n

\\[ b = \\var{rinv11} \\equiv \\var{inv11} \\bmod{11}.\\]

\n

Last Question

\n

The last question's answers are found by, for example in $\\mathbb{Z}_{7}$, considering (all $\\bmod 7$)

\n

\\[\\frac{\\var{c3}}{\\var{b3}} = \\var{c3} \\times \\frac{1}{\\var{b3}} \\equiv \\var{c3} \\times \\var{inv7} \\equiv \\var{c3*inv7} \\equiv \\var{minv7} \\bmod{7}.\\]

"}]}], "contributors": [{"name": "Blathnaid Sheridan", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/447/"}], "extensions": [], "custom_part_types": [], "resources": []}