login
List prime factors of each number in order (each prime factor is followed by its power). Start with 1 = {1,1}.
2

%I #32 Jun 07 2024 14:24:03

%S 1,1,2,1,3,1,2,2,5,1,2,1,3,1,7,1,2,3,3,2,2,1,5,1,11,1,2,2,3,1,13,1,2,

%T 1,7,1,3,1,5,1,2,4,17,1,2,1,3,2,19,1,2,2,5,1,3,1,7,1,2,1,11,1,23,1,2,

%U 3,3,1,5,2,2,1,13,1,3,3,2,2,7,1,29,1,2,1,3,1,5,1,31,1,2,5,3,1,11,1,2

%N List prime factors of each number in order (each prime factor is followed by its power). Start with 1 = {1,1}.

%C This entry also serves to show how to factor numbers in various languages.

%C Memo: in Maple, use ifactors, not ifactor!

%C Length of n-th row = 2*A001221(n). - _Reinhard Zumkeller_, Jan 10 2013

%H Reinhard Zumkeller, <a href="/A035306/b035306.txt">Rows n = 1..1000 of triangle, flattened</a>

%F For 1 <= k <= A001221(n): T(n,2*k-1) = A027748(n,k), T(n,2*k) = A124010(n,k). - _Reinhard Zumkeller_, Jan 10 2013

%e The table starts as follows:

%e n | (p, valuation_p(n)) for primes p | n

%e ----+---------------------------------------

%e 1 | (1, 1), (row 1, by definition of this sequence)

%e 2 | (2, 1), (i.e.: 2 = 2^1)

%e 3 | (3, 1),

%e 4 | (2, 2), (i.e.: 4 = 2^2)

%e 5 | (5, 1),

%e 6 | (2, 1), (3, 1), (i.e.: 6 = 2^1 * 3^2)

%e 7 | (7, 1),

%e 8 | (2, 3),

%e 9 | (3, 2),

%e 10 | (2, 1), (5, 1),

%e 11 | (11, 1),

%e 12 | (2, 2), (3, 1),

%e 13 | (13, 1),

%e 14 | (2, 1), (7, 1),

%e 15 | (3, 1), (5, 1),

%e 16 | (2, 4),

%e 17 | (17, 1),

%e 18 | (2, 1), (3, 2),

%e ... | ...

%p ListTools[Flatten]([[[1, 1]], seq(op(2..-1, ifactors(n)), n=2..34)], 2); # _Peter Luschny_, Sep 02 2018

%t Flatten[ Array[ FactorInteger[ # ]&, 40 ] ]

%o (Haskell)

%o import Data.List (transpose)

%o a035306 n k = a035306_row n !! (k-1)

%o a035306_row 1 = [1,1]

%o a035306_row n = concat $ transpose [a027748_row n, a124010_row n]

%o a035306_tabf = map a035306_row [1..]

%o -- _Reinhard Zumkeller_, Jan 10 2013

%o (Magma) [ Factorization(n) : n in [1..120]];

%o (PARI) upto(n) = {n = max(n, 1); my(res = List([1, 1])); for(i = 2, n, f = factor(i); for(j = 1, #f~, listput(res, f[j, 1]); listput(res, f[j, 2]))); res} \\ _David A. Corneth_, Sep 02 2018

%o (PARI) A035306_row(n)=if(n>1, concat(Col(factor(n))~), [1, 1]) \\ _M. F. Hasler_, Jun 04 2024

%o (Python) A035306_row = lambda n: [x for f in factorint(n).items() for x in f]

%o from sympy import factorint # _M. F. Hasler_, Jun 06 2024

%Y Cf. A008474 (row sums, apart from initial row).

%Y Cf. A001221, A001222, A027748, A124010.

%K nonn,tabf

%O 1,3

%A _N. J. A. Sloane_.