// Numbas version: finer_feedback_settings {"name": "Solve an equation in modular arithmetic", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [], "variables": {"sb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(30..60)", "description": "", "name": "sb"}, "r1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(10..sb-1)", "description": "", "name": "r1"}, "ans3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mod(r*ans2,sb)", "description": "", "name": "ans3"}, "ans2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mod(csa,sb)", "description": "", "name": "ans2"}, "mess": {"templateType": "anything", "group": "Ungrouped variables", "definition": "\n\n\nif(csa<0,\n\n'A positive inverse of $\\\\var{sa} \\\\; \\\\mod\\\\;\\\\var{sb}$ in the range $0\\\\le x \\\\le \\\\var{sb-1}$ is given by $\\\\simplify[]{{csa}+{sb}}\\\\;\\\\mod\\\\;\\\\var{sb}\\=\\\\var{mod(csa,sb)}\\\\;\\\\mod\\\\;\\\\var{sb}$\\n\\n.'\n\n,\n\n'Hence the inverse of $\\\\var{sa}$ in $\\\\mathbb{Z}_{\\\\var{sb}}$ is give by $x=\\\\var{mod(csa,sb)}$.'\n\n)\n\n\n", "description": "", "name": "mess"}, "csb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "extendedgcd2(sa,sb)", "description": "", "name": "csb"}, "csa": {"templateType": "anything", "group": "Ungrouped variables", "definition": "extendedgcd1(sa,sb)", "description": "", "name": "csa"}, "sa": {"templateType": "anything", "group": "Ungrouped variables", "definition": "chcop(sb,sb)", "description": "", "name": "sa"}, "r": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(r1=sa,r1-1,r1)", "description": "", "name": "r"}}, "ungrouped_variables": ["r1", "mess", "ans2", "ans3", "csa", "csb", "r", "sb", "sa"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "name": "Solve an equation in modular arithmetic", "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"]]}, "chcop": {"type": "number", "language": "jme", "definition": "if(gcd(a,b)=1,b,chcop(a,random(10..a-1)))", "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"]]}, "mdescextgcd": {"type": "html", "language": "javascript", "definition": "var table=$('
$\\\\var{'+a+'}$ | $\\\\var{'+b+'}$ | $'+ disp(c1+'a+'+c2+'b')+'$ | $'+ disp(d1+'a+'+d2+'b')+'$ | $\\\\var{'+a+'}$ | $\\\\var{'+b+'}-\\\\var{'+fl+'}\\\\times\\\\var{'+a+'}$ | $'+ disp(c1+'a+'+c2+'b')+'$ | $'+disp(d1+'a+'+d2+'b-'+fl+'('+c1+'a+'+c2+'b'+')')+'$ | ');\n mdescextgcd(a,b%a,c1,c2,d1-fl*c1,d2-fl*c2);\n }\n else {\nvar fl1=Math.floor(a/b);\ntable.append('
$\\\\var{'+a+'}-\\\\var{'+fl1+'}\\\\times\\\\var{'+b+'}$ | $\\\\var{'+b+'}$ | $'+disp(c1+'a+'+c2+'b-'+fl1+'('+d1+'a+'+d2+'b'+')')+'$ | $'+ disp(d1+'a+'+d2+'b')+'$ |