<! DOCTYPE html>
<meta charset= "UTF-8" >
<title>Title</title>
<script type= "Text/javascript" >
var num = prompt ("Please enter a positive integer for the factor you want to decompose:", "1")
if (IsNaN (num) = = true) {
num = prompt ("Please enter a positive integer for the factor you want to decompose:", "1")
}
if (num <= 0) {
num = prompt ("Please enter a positive integer for the factor you want to decompose:", "1")
}
num = parseint (num);
var nump = num;
var arrfactor = [];
var L = 0;
var arrprem = [];
var k = 0;
for (var i = 2; i < num; i + +) {
var isprem = true;
for (var j = 2; J < I; J + +) {
if (i% j = 0) {
Isprem = false;
}
}
if (Isprem = = True) {
Arrprem[k] = i;
K + +;
}
}
for (var i = 0; i < arrprem.length;) {
if (num% arrprem[i] = = 0) {
num = Num/arrprem[i];
ARRFACTOR[L] = Arrprem[i];
L + +;
i = 0;
}else{
i + +;
}
}
document.write ("positive integer" + nump + "=");
if (Arrfactor.length = = 0) {
document.write ("You enter the number of ...")
}else{
for (var i = 0; i < arrfactor.length-1; i + +) {
document.write (Arrfactor[i] + "x");
}
document.write (Arrfactor[arrfactor.length-1]);
}
</script>
<body>
</body>
Factorization of factorization in JS