// Numbas version: finer_feedback_settings {"name": "Division/Extended Euclidean Algorithm", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Division/Extended Euclidean Algorithm", "tags": ["pure"], "metadata": {"description": "

Useful for students' revision. Assesses ability to apply the algorithms correctly. Question has randomised values.

", "licence": "All rights reserved"}, "statement": "

This question will test your use of the Division Algorithm and the Extended Euclidean Algorithm.

", "advice": "", "rulesets": {}, "extensions": [], "variables": {"a": {"name": "a", "group": "Ungrouped variables", "definition": "random(4..70)", "description": "", "templateType": "anything"}, "b": {"name": "b", "group": "Ungrouped variables", "definition": "random(4..70)", "description": "", "templateType": "anything"}, "out": {"name": "out", "group": "Ungrouped variables", "definition": "EEA(a,b)", "description": "", "templateType": "anything"}, "gcd": {"name": "gcd", "group": "Ungrouped variables", "definition": "out[0]", "description": "", "templateType": "anything"}, "x": {"name": "x", "group": "Ungrouped variables", "definition": "out[1]", "description": "", "templateType": "anything"}, "y": {"name": "y", "group": "Ungrouped variables", "definition": "out[2]", "description": "", "templateType": "anything"}, "bdiv": {"name": "bdiv", "group": "Division algorithm", "definition": "random(2..25)", "description": "", "templateType": "anything"}, "adiv": {"name": "adiv", "group": "Division algorithm", "definition": "random(1..80)+bdiv", "description": "", "templateType": "anything"}, "qdiv": {"name": "qdiv", "group": "Division algorithm", "definition": "floor(adiv/bdiv)", "description": "", "templateType": "anything"}, "rdiv": {"name": "rdiv", "group": "Division algorithm", "definition": "mod(adiv,bdiv)", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["a", "b", "out", "gcd", "x", "y"], "variable_groups": [{"name": "Division algorithm", "variables": ["adiv", "bdiv", "qdiv", "rdiv"]}], "functions": {"EEA": {"parameters": [["ain", "number"], ["bin", "number"]], "type": "list", "language": "javascript", "definition": "function earec(a,b,s,t){\n r = a % b;\n if (r < 1) {\n return [b,s[1],t[1]];\n }\n else {\n q = Math.floor(a/b);\n snew = s[0]-q*s[1];\n tnew = t[0]-q*t[1];\n s[0] = s[1];\n s[1] = snew;\n t[0] = t[1];\n t[1] = tnew;\n return earec(b,r,s,t);\n }\n}\n\na=ain;\nb=bin;\nif (a < b) {\n a = bin;\n b = ain;\n}\ns=[1,0];\nt=[0,1];\nout = earec(a,b,s,t);\n//this loop sorts out x and y if a is less than b\nif (ain < bin) {\n tempx = out[1];\n out[1]=out[2];\n out[2]=tempx;\n}\nreturn out;"}}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "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": "

Use the division algorithm to find the quotient q and the remainder r when dividing $\\var{adiv}$ by $\\var{bdiv}$.

\n

q = [[0]], r = [[1]]

", "gaps": [{"type": "numberentry", "useCustomName": true, "customName": "q", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "qdiv", "maxValue": "qdiv", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "r", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "rdiv", "maxValue": "rdiv", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}, {"type": "gapfill", "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": "

The gcd of $\\var{a}$ and $\\var{b}$ is [[0]].

", "gaps": [{"type": "numberentry", "useCustomName": true, "customName": "GCD", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "gcd", "maxValue": "gcd", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}, {"type": "gapfill", "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": "

$gcd(\\var{a},\\var{b})=$ [[0]]x$\\var{a} +$ [[1]]x$\\var{b}$

", "gaps": [{"type": "numberentry", "useCustomName": true, "customName": "1", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "out[1]", "maxValue": "out[1]", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "2", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "out[2]", "maxValue": "out[2]", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "type": "question", "contributors": [{"name": "Will Foreman", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7659/"}]}]}], "contributors": [{"name": "Will Foreman", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7659/"}]}