A263987
Number of ways of ordering integers 1 to n such that each number is either a factor of or larger than its predecessor.
Original entry on oeis.org
1, 1, 2, 4, 14, 28, 164, 328, 2240, 9970, 63410, 126820, 1810514, 3621028, 31417838, 294911038, 3344414606, 6688829212, 121919523980, 243839047960, 5307482547686, 56885719183654, 468469574780468, 936939149560936, 33136077712470338, 249693200433310492
Offset: 0
For n=4, the allowable sequences are: (1,2,3,4), (1,3,4,2), (1,4,2,3), (2,1,3,4), (2,3,1,4), (2,3,4,1), (2,4,1,3), (3,1,2,4), (3,1,4,2), (3,4,1,2), (3,4,2,1), (4,1,2,3), (4,2,1,3), (4,2,3,1).
-
b:= proc(i, s) option remember; `if`(s={}, 1, add(
`if`(j>i or irem(i, j)=0, b(j, s minus {j}), 0), j=s))
end:
a:= n-> add(b(i, {$1..n} minus {i}), i=signum(n)..n):
seq(a(n), n=0..15); # Alois P. Heinz, Oct 31 2015
-
b[i_, s_] := b[i, s] = If[s == {}, 1, Sum[If[j > i || Mod[i, j] == 0, b[j, s ~Complement~ {j}], 0], {j, s}]];
a[n_] := Sum[b[i, Range[n] ~Complement~ {i}], {i, 1, n}];
Array[a, 12] (* Jean-François Alcover, Nov 28 2020, after Alois P. Heinz *)
-
a(n) = {nb = 0; for (k=0, n!-1, perm = numtoperm(n, k); ok = 1; for (j=2, n, if ((perm[j] % perm[j-1]) && (perm[j] > perm[j-1]), ok=0; break);); if (ok, nb++);); nb;} \\ Michel Marcus, Nov 02 2015
-
from itertools import permutations
def a(n):
count = 0
for i in permutations(range(1, n+1), r=n):
for j in range(len(i)-1):
if i[j]%i[j+1]!=0 and i[j]>i[j+1]:
break
else:
count+=1
return count
for i in range(0, 10):
print(a(i), end=", ")
-
from functools import cache
@cache
def b(i, s): return 1 if s == tuple() else sum(b(j, tuple(sorted(set(s)-{j}))) if j>i or i%j==0 else 0 for j in s)
def a(n): return 1 if n==0 else sum(b(i, tuple(sorted(set(range(1, n+1))-{i}))) for i in range(1, n+1))
print([a(n) for n in range(15)]) # Michael S. Branicky, Feb 25 2024 after Alois P. Heinz
A333892
Number of permutations sigma of [n] such that i divides Product_{k=1..i} sigma(k) for 1 <= i <= n.
Original entry on oeis.org
1, 1, 2, 4, 14, 36, 320, 1328, 7872, 51552, 756480, 5440752, 68999136, 584117952, 9632932800, 152699071104, 1881048314880, 21977611223040, 343998708042240, 4374197540536320, 77078374650869760, 1646804888482037760, 45052372505959096320, 727420047420178022400
Offset: 0
a(5) = 36: 12345, 14325, 14352, 21345, 23145, 23415, 23451, 23541, 24315, 24351, 25341, 32145, 32415, 32451, 32541, 34125, 34152, 34215, 34251, 34512, 34521, 41325, 41352, 42315, 42351, 43125, 43152, 43215, 43251, 43512, 43521, 45312, 45321, 52341, 54312, 54321.
-
b:= proc(s) option remember; (n-> `if`(n=0, 1, `if`(irem(
mul(i, i=s), n)=0, add(b(s minus {j}), j=s), 0)))(nops(s))
end:
a:= n-> b({$1..n}):
seq(a(n), n=0..17); # Alois P. Heinz, Apr 09 2020
-
b[s_] := b[s] = With[{n = Length[s]}, If[n==0, 1, If[Mod[Times@@s, n]==0, Sum[b[s ~Complement~ {j}], {j, s}], 0]]];
a[n_] := b[Range[n]];
a /@ Range[0, 20] (* Jean-François Alcover, Nov 16 2020, after Alois P. Heinz *)
-
{a(n) = if(n==0, 1, my(k=0); forperm([1..n], p, if(#Set(vector(n, i, prod(j=1, i, p[j])%i))==1, k++)); k)}
A333711
Number of permutations of [n] such that the product of the first k elements and the product of the last k elements are multiples of k! for all k in [n].
Original entry on oeis.org
1, 1, 2, 2, 8, 4, 32, 4, 96, 244, 1400, 20, 3988, 12, 256, 1328, 3107082, 7900, 4352004, 2676, 752280, 4710724, 23591664, 672, 79424164, 51627164, 4705224, 802988332, 25488756038104, 47736592, 1706618983956, 826828
Offset: 0
a(4) = 8: 1234, 1432, 2134, 2314, 2341, 4132, 4312, 4321.
a(5) = 4: 12345, 14325, 52341, 54321.
a(7) = 4: 1234567, 1654327, 7234561, 7654321.
a(13) = 12: 123456789(10)(11)(12)(13), 143256789(10)(11)(12)(13), 143(10)987652(11)(12)(13), 1(12)(11)256789(10)34(13), 1(12)(11)(10)98765234(13), 1(12)(11)(10)98765432(13), (13)23456789(10)(11)(12)1, (13)43256789(10)(11)(12)1, (13)43(10)987652(11)(12)1, (13)(12)(11)256789(10)341, (13)(12)(11)(10)987652341, (13)(12)(11)(10)987654321.
-
b:= proc(s, n) option remember; (m-> `if`(m=0, 1, `if`(irem(
mul(h, h=({$1..n} minus s)), (n-m)!)=0 and irem(mul(h,
h=s), m!)=0, add(b(s minus {j}, n), j=s), 0)))(nops(s))
end:
a:= n-> b({$1..n}, n):
seq(a(n), n=0..17);
-
b[s_, n_] := b[s, n] = With[{m = Length[s]}, If[m == 0, 1, If[Mod[ Product[h, {h, Range[n] ~Complement~ s}], (n-m)!] == 0 && Mod[Times@@s, m!] == 0, Sum[b[s ~Complement~ {j}, n], {j, s}], 0]]];
a[n_] := b[Range[n], n];
Table[Print[n, " ", a[n]]; a[n], {n, 0, 27}] (* Jean-François Alcover, Nov 01 2021, after Alois P. Heinz *)
Showing 1-3 of 3 results.