// Numbas version: exam_results_page_options {"name": "Michael's copy of Show the prime factorisation of a number", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [], "functions": {"show_factors": {"parameters": [["n", "number"]], "definition": "latex( // mark the output as a string of raw LaTeX\n join(\n map(\n if(a=1,p,p+'^{'+a+'}'), // when the exponent is 1, return p, otherwise return p^{exponent}\n [p,a],\n filter(x[1]>0,x,zip(primes,factorise(n))) // for all the primes p which are factors of n, return p and its exponent\n ),\n ' \\\\times ' // join all the prime powers up with \\times symbols\n )\n)", "language": "jme", "type": "string"}}, "parts": [], "advice": "", "extensions": [], "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

A function which renders the factorisation of a number in LaTeX.

"}, "ungrouped_variables": ["primes", "a", "f"], "name": "Michael's copy of Show the prime factorisation of a number", "tags": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "statement": "

$\\var{a} = \\var{show_factors(a)}$

", "rulesets": {}, "preamble": {"css": "", "js": ""}, "variables": {"primes": {"templateType": "anything", "description": "", "group": "Ungrouped variables", "name": "primes", "definition": "[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]"}, "f": {"templateType": "anything", "description": "

show_factors is defined in the Extensions & Scripts tab

", "group": "Ungrouped variables", "name": "f", "definition": "show_factors(a)"}, "a": {"templateType": "anything", "description": "", "group": "Ungrouped variables", "name": "a", "definition": "random(1..50)"}}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Michael Proudman", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/269/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Michael Proudman", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/269/"}]}