2以上の任意の自然数Nを素因数分解するコードです。このコードはJavaScriptで書かれています。
var N = ; var passed_p_memory = []; var p_memory = []; var t_memory = []; function mod_p(v1) { if (v1 === 2) { return ; } else { for (var n1 = 0; n1 < passed_p_memory.length; n1 = (n1 + 1)) { if ((v1 % passed_p_memory[n1]) === 0) { return 0; break; } else { if (n1 === (passed_p_memory.length - 1)) { return ; break; } else { continue; }; }; }; }; }; function p_recoder(v1) { if (p_memory.includes(v1) === true) { } else { p_memory.push(v1); }; return ; }; function t_recoder(v1) { if (t_memory[p_memory.indexOf(v1)] === undefined) { t_memory.push(1); } else { t_memory[p_memory.indexOf(v1)] = (t_memory[p_memory.indexOf(v1)] + 1); }; return ; }; var re_N = N; for (var n2 = 2; n2 <= re_N; n2 = (n2 + 1)) { if (mod_p(n2) === 0) { continue; } else { passed_p_memory.push(n2); while ((re_N % n2) === 0) { p_recoder(n2); t_recoder(n2); var re_N = (re_N / n2); }; continue; }; }; var answer = (p_memory[0] + '^' + t_memory[0]); if (p_memory.length === 1) { console.log(N + ' = ' + answer); } else { for (var n3 = 1; n3 < p_memory.length; n3 = (n3 + 1)) { var answer = (answer + ' * ' + p_memory[n3] + '^' + t_memory[n3]); }; console.log(N + ' = ' + answer); };