OFFSET
1,2
COMMENTS
n-th row has length A001222(n) (n>1).
LINKS
N. J. A. Sloane, First 2048 rows of triangle, flattened
S. von Worley (?), Animated Factorization Diagrams, Oct. 2012.
Brent Yorgey, Factorization diagrams, The Math Less Traveled, Oct 05 2012.
FORMULA
EXAMPLE
Triangle begins
1;
2;
3;
2, 2;
5;
2, 3;
7;
2, 2, 2;
3, 3;
2, 5;
11;
2, 2, 3;
...
MAPLE
P:=proc(n) local FM: FM:=ifactors(n)[2]: seq(seq(FM[j][1], k=1..FM[j][2]), j=1..nops(FM)) end: 1; for n from 2 to 45 do P(n) od; # yields sequence in triangular form; Emeric Deutsch, Feb 13 2005
MATHEMATICA
row[n_] := Flatten[ Table[#[[1]], {#[[2]]}] & /@ FactorInteger[n]]; Flatten[ Table[ row[n], {n, 1, 45}]] (* Jean-François Alcover, Dec 01 2011 *)
PROG
(Haskell)
import Data.List (unfoldr)
a027746 n k = a027746_tabl !! (n-1) !! (k-1)
a027746_tabl = map a027746_row [1..]
a027746_row 1 = [1]
a027746_row n = unfoldr fact n where
fact 1 = Nothing
fact x = Just (p, x `div` p) where p = a020639 x
-- Reinhard Zumkeller, Aug 27 2011
(PARI) A027746_row(n, o=[1])=if(n>1, concat(apply(t->vector(t[2], i, t[1]), Vec(factor(n)~))), o) \\ Use %(n, []) if you want the more natural [] for the first row. - M. F. Hasler, Jul 29 2015
(Sage) v=[1]
for k in [2..45]: v.extend(p for (p, m) in factor(k) for _ in range(m))
print(v) # Giuseppe Coppoletta, Dec 29 2017
(Python)
def factors(n: int) -> list[int]:
p = n
L:list[int] = []
for f in range(2, p + 1):
if f * f > p: break
while True:
q, r = divmod(p, f)
if r != 0: break
L.append(f)
p = q
if p == 1: return L
L.append(p)
return L # Peter Luschny, Jul 18 2024
CROSSREFS
KEYWORD
nonn,easy,nice,tabf
AUTHOR
EXTENSIONS
More terms from James A. Sellers
STATUS
approved