// Numbas version: finer_feedback_settings {"name": "Legendre symbol+Jacobi symbol", "extensions": [], "custom_part_types": [{"source": {"pk": 4, "author": {"name": "Christian Lawson-Perfect", "pk": 7}, "edit_page": "/part_type/4/edit"}, "name": "Number entry modulo", "short_name": "number-entry-modulo", "description": "

The student's answer should be equivalent to the expected answer modulo the base set by the question author.

", "help_url": "", "input_widget": "number", "input_options": {"correctAnswer": "string(mod(settings[\"expected\"],settings[\"modulo\"]))", "hint": {"static": false, "value": "if(settings[\"show_hint\"], \"$\\\\pmod{\"+settings[\"modulo\"]+\"}$\", \"\")"}, "allowedNotationStyles": {"static": true, "value": ["plain", "en", "si-en"]}, "allowFractions": {"static": true, "value": true}}, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\ncorrectif(interpreted_answer = expected_modulo)\n\ninterpreted_answer:\nmod(studentanswer,settings[\"modulo\"])\n\nexpected_modulo:\nmod(settings[\"expected\"],settings[\"modulo\"])", "marking_notes": [{"name": "mark", "description": "This is the main marking note. It should award credit and provide feedback based on the student's answer.", "definition": "correctif(interpreted_answer = expected_modulo)"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "mod(studentanswer,settings[\"modulo\"])"}, {"name": "expected_modulo", "description": "

The expected answer, modulo the base.

", "definition": "mod(settings[\"expected\"],settings[\"modulo\"])"}], "settings": [{"name": "expected", "label": "Expected answer", "help_url": "", "hint": "

Answers congruent to this number, modulo the base defined below, will be marked correct.

", "input_type": "code", "default_value": "", "evaluate": true}, {"name": "modulo", "label": "Base", "help_url": "", "hint": "Answers are compared modulo this number.", "input_type": "code", "default_value": "10", "evaluate": true}, {"name": "show_hint", "label": "Show modulo hint?", "help_url": "", "hint": "If ticked, $\\pmod{\\texttt{base}}$ will be shown to the right of the input box.", "input_type": "checkbox", "default_value": true}], "public_availability": "always", "published": true, "extensions": []}], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Legendre symbol+Jacobi symbol", "tags": ["Number theory", "pure"], "metadata": {"description": "

Asks students to calculate a Legendre symbol.

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

This question asks you to calculate a Legendre Symbol.

", "advice": "", "rulesets": {}, "extensions": [], "variables": {"a": {"name": "a", "group": "Ungrouped variables", "definition": "random(-100..100)", "description": "

top of the Legendre symbol

", "templateType": "anything"}, "p": {"name": "p", "group": "Ungrouped variables", "definition": "\nrandom(3,5,7,11,13,17,19)", "description": "

Randomised odd prime.

", "templateType": "anything"}, "LS": {"name": "LS", "group": "Ungrouped variables", "definition": "Legendre(a,p)", "description": "

The solution

", "templateType": "anything"}, "m": {"name": "m", "group": "Ungrouped variables", "definition": "random(-100..100)", "description": "", "templateType": "anything"}, "n": {"name": "n", "group": "Ungrouped variables", "definition": "calcfrompl(primelist,nlist)", "description": "", "templateType": "anything"}, "primelist": {"name": "primelist", "group": "Ungrouped variables", "definition": "[ 3, 5, 7, 11, 13, 17, 19, 23 ]", "description": "", "templateType": "list of numbers"}, "nlist": {"name": "nlist", "group": "Ungrouped variables", "definition": "RandOddInt(4)", "description": "", "templateType": "anything"}, "JS": {"name": "JS", "group": "Ungrouped variables", "definition": "Jacobi(m,primelist,nlist)", "description": "

Calculated value of the Jacobi symbol $(\\frac{\\var{m}}{\\var{n}})$

", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["a", "p", "LS", "m", "n", "primelist", "nlist", "JS"], "variable_groups": [], "functions": {"Legendre": {"parameters": [["a", "number"], ["p", "number"]], "type": "number", "language": "javascript", "definition": "//calculate the LS\nout = math.pow(a,((p-1)/2)) % p;\n// get this into the form +-1/0\nwhile (out > 1 || out < -1) {\n if (out > 1) {\n out = out - p;\n }\n if (out < -1) {\n out = out + p;\n }\n}\nreturn out;"}, "RandOddInt": {"parameters": [["listleng", "number"]], "type": "list", "language": "javascript", "definition": "flist = [];\ncount = 0;\nwhile (count < listleng) {\n if (count < 2) {\n flist.push(Math.floor((Math.random() * 4)));\n }\n else {\n flist.push(Math.floor((Math.random())));\n }\n count = count + 1;\n}\nreturn flist;"}, "calcfrompl": {"parameters": [["primes", "list"], ["powers", "list"]], "type": "number", "language": "javascript", "definition": "cycles = powers.length;\ncount = 0;\nout = 1;\nwhile (count < cycles) {\n out = out * Math.pow(primes[count],powers[count]);\n count = count + 1;\n}\nreturn out;"}, "Jacobi": {"parameters": [["m", "number"], ["primes", "list"], ["powers", "list"]], "type": "number", "language": "javascript", "definition": "function Legendre(a,p) {\n //calculate the LS\n out = math.pow(a,((p-1)/2)) % p;\n // get this into the form +-1/0\n while (out > 1 || out < -1) {\n if (out > 1) {\n out = out - p;\n }\n if (out < -1) {\n out = out + p;\n }\n } \nreturn out;\n}\n\nout = 1;\ncount = 0;\ncycles = powers.length;\nwhile (count < cycles){\n if (powers[count]!=0){ \n out = out * Math.pow(Legendre(m,primes[count]),powers[count]);\n }\n count = count + 1;\n}\nreturn out;"}}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "number-entry-modulo", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Calculate the Legendre symbol $(\\frac{\\var{a}}{\\var{p}})$

", "alternatives": [{"type": "number-entry-modulo", "useCustomName": true, "customName": "Correctmodp", "marks": "0.5", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "alternativeFeedbackMessage": "

Remember to reduce mod p. Your answer should be -1, 0 or 1.

", "useAlternativeFeedback": false, "settings": {"expected": "LS", "modulo": "p", "show_hint": false}}], "settings": {"expected": "LS", "modulo": "200", "show_hint": false}}, {"type": "number-entry-modulo", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Calculate the Jacobi symbol $(\\frac{\\var{m}}{\\var{n}})$

", "alternatives": [{"type": "number-entry-modulo", "useCustomName": true, "customName": "correctmodn", "marks": "0.5", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "alternativeFeedbackMessage": "

Remember to reduce as you go and give your answer as -1, 0 or 1.

", "useAlternativeFeedback": false, "settings": {"expected": "JS", "modulo": "n", "show_hint": false}}], "settings": {"expected": "JS", "modulo": "400", "show_hint": 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/"}]}