Task

Write a program which counts up from   1,   displaying each number as the multiplication of its prime factors.

For the purpose of this task,   1   (unity)   may be shown as itself.



Example

      2   is prime,   so it would be shown as itself.

      6   is not prime;   it would be shown as   



2
×
3


{\displaystyle 2\times 3}

.
2144   is not prime;   it would be shown as   



2
×
2
×
2
×
2
×
2
×
67


{\displaystyle 2\times 2\times 2\times 2\times 2\times 67}

.



Related tasks

   prime decomposition
   factors of an integer
   Sieve of Eratosthenes
   primality by trial division
   factors of a Mersenne number
   trial factoring of a Mersenne number
   partition an integer X into N primes


100 PROGRAM "Factors.bas"
110 FOR I=1 TO 30
120   PRINT I;"= ";FACTORS$(I)
130 NEXT
140 DEF FACTORS$(N)
150   LET F$=""
160   IF N=1 THEN
170     LET FACTORS$="1"
180   ELSE
190     LET P=2
200     DO WHILE P<=N
210       IF MOD(N,P)=0 THEN
220         LET F$=F$&STR$(P)&"*"
230         LET N=INT(N/P)
240       ELSE
250         LET P=P+1
260       END IF
270     LOOP
280     LET FACTORS$=F$(1:LEN(F$)-1)
290   END IF
300 END DEF