let input = '1' let num = parseInt(input); if(num == 1){ console.log(num); } let result = []; let i = 2; while(i <= num && i*i <= num){ if(num % i === 0){ result.push(i); num /= i; i = 2; }else{ i++; } } if(num != 1){ result.push(num) } console.log(result.toString().replace(/,/g, ' '))