Problem:
Enter 6
Export 1*2*3
1. List of build primes
2. A list of primes from the sequence of prime numbers, n except for gold, this hypothesis is inseparable, the Prime table index + +, in addition, n/= Prime, continue to reason
3. Traverse table
4. Limited: Need to be large enough, assuming the number is large, this algorithm needs to change
JS implementation:
function P (n) {if (n<2) {return 0;} if (n = = 2) {return 1;} for (var i = 2; i < n; i++) {if (n%i = = 0) {return 0;}} return 1;} var pl = new Array (), for (var i = 2,index = 0;index<100;i++) {if (P (i) = = 1) {Pl.push (i); index++;}} function f (n) {var pindex = 0;var ret = "1"; for (;p index<100;) {if (n% pl[pindex] = = 0) {ret + = "*" + pl[pindex]; n/=pl[pindex];} Else{if (P (n)) {ret + = "*" + n;return ret;} Pindex + +;}} return ret;} Console.log (f (111223));
Motion algorithm--the product of integers being divided into prime numbers