let n = 25;

// u prvoj fazi odredjujemo najmanji prost cinilac svakog broja od 2 do n
let minFactor = [];
for (let k = 0; k <= n; k++)
    minFactor.push(k);
for (let d = 2; d * d <= n; d++) {
    if (minFactor[d] == d) {
       for (let k = d * d; k <= n; k += d) {
            if (minFactor[k] == k)
                minFactor[k] = d;
       }
    }
}

// u drugoj fazi faktorisemo svaki broj od 2 do n
for (let m = 2; m <= n; m++) {
    let mm = m;
    let factors = [];
    while (mm > 1) {
        factors.push(minFactor[mm]);
        mm /= minFactor[mm];
    }
}