// Numbas version: exam_results_page_options {"name": "Marlon'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": [{"variablesTest": {"condition": "", "maxRuns": 100}, "tags": [], "extensions": [], "parts": [], "ungrouped_variables": ["primes", "a", "f"], "preamble": {"css": "", "js": ""}, "variable_groups": [], "name": "Marlon's copy of Show the prime factorisation of a number", "rulesets": {}, "variables": {"f": {"description": "

show_factors is defined in the Extensions & Scripts tab

", "definition": "show_factors(a)", "group": "Ungrouped variables", "templateType": "anything", "name": "f"}, "a": {"description": "", "definition": "random(1..50)", "group": "Ungrouped variables", "templateType": "anything", "name": "a"}, "primes": {"description": "", "definition": "[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]", "group": "Ungrouped variables", "templateType": "anything", "name": "primes"}}, "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

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

"}, "functions": {"show_factors": {"type": "string", "parameters": [["n", "number"]], "language": "jme", "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)"}}, "advice": "", "statement": "

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

", "type": "question", "contributors": [{"name": "Marlon Arcila", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/321/"}]}]}], "contributors": [{"name": "Marlon Arcila", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/321/"}]}