A162247 Irregular triangle in which row n lists all factorizations of n, sorted by the number of factors in each factorization.
1, 2, 3, 4, 2, 2, 5, 6, 2, 3, 7, 8, 2, 4, 2, 2, 2, 9, 3, 3, 10, 2, 5, 11, 12, 2, 6, 3, 4, 2, 2, 3, 13, 14, 2, 7, 15, 3, 5, 16, 2, 8, 4, 4, 2, 2, 4, 2, 2, 2, 2, 17, 18, 2, 9, 3, 6, 2, 3, 3, 19, 20, 2, 10, 4, 5, 2, 2, 5, 21, 3, 7, 22, 2, 11, 23, 24, 2, 12, 3, 8, 4, 6, 2, 2, 6, 2, 3, 4, 2, 2, 2, 3, 25, 5, 5
Offset: 1
Examples
1; 2; 3; 4,2*2; 5; 6,2*3; 7; 8,2*4,2*2*2; 9,3*3; 10,2*5; 11; 12,2*6,3*4,2*2*3;
References
- See A001055.
Links
- T. D. Noe, Rows n=1..1000 of triangle, flattened
- R. J. Mathar, Factorizations of n=1..1100
Programs
-
Haskell
import Data.List (sortBy) import Data.Ord (comparing) a162247 n k = a162247_tabl !! (n-1) !! (k-1) a162247_row n = a162247_tabl !! (n-1) a162247_tabl = map (concat . sortBy (comparing length)) $ tail fss where fss = [] : map fact [1..] where fact x = [x] : [d : fs | d <- [2..x], let (x',r) = divMod x d, r == 0, fs <- fss !! x', d <= head fs] -- Reinhard Zumkeller, Jan 08 2013
-
Mathematica
g[lst_,p_] := Module[{t,i,j}, Union[Flatten[Table[t=lst[[i]]; t[[j]]=p*t[[j]]; Sort[t], {i,Length[lst]}, {j,Length[lst[[i]]]}], 1], Table[Sort[Append[lst[[i]],p]], {i,Length[lst]}]]]; f[n_] := Module[{i,j,p,e,lst={{}}}, {p,e}=Transpose[FactorInteger[n]]; Do[lst=g[lst,p[[i]]], {i,Length[p]}, {j,e[[i]]}]; lst]; Flatten[Table[f[n], {n,25}]]
Comments