cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A321686 Triangle read by rows: T(n,k) is the sum of the number of the arrangements of p_1 1's, p_2 2's, ..., p_k k's (p_1 + p_2 + ... + p_k = n and p_1 >= p_2 >= ... >= p_k) avoiding equal consecutive terms, where 1 <= k <= n.

This page as a plain text file.
%I A321686 #43 Dec 15 2024 04:35:44
%S A321686 1,0,2,0,1,6,0,2,6,24,0,1,14,36,120,0,2,40,108,240,720,0,1,59,348,900,
%T A321686 1800,5040,0,2,112,1486,3300,8160,15120,40320,0,1,287,3056,15744,
%U A321686 33960,80640,141120,362880,0,2,448,10012,76776,180000,378000,866880,1451520,3628800
%N A321686 Triangle read by rows: T(n,k) is the sum of the number of the arrangements of p_1 1's, p_2 2's, ..., p_k k's (p_1 + p_2 + ... + p_k = n and p_1 >= p_2 >= ... >= p_k) avoiding equal consecutive terms, where 1 <= k <= n.
%H A321686 Seiichi Manyama, <a href="/A321686/b321686.txt">Rows n = 1..30, flattened</a>
%e A321686 In case of n=4.
%e A321686             | p_1 1's, p_2 2's, | Arrangements satisfying
%e A321686   Partition |   ..., p_k k's    |      the condition
%e A321686   ----------+-------------------+---------------------------
%e A321686   4         |              1111 |
%e A321686   3+1       |              1112 |
%e A321686   2+2       |              1122 | 1212, 2121.
%e A321686   2+1+1     |              1123 | 1213, 1231, 2131,
%e A321686             |                   | 1312, 1321, 3121.
%e A321686   1+1+1+1   |              1234 | 1234, 1243, ... (24 terms)
%e A321686   So T(4,1) = 0, T(4,2) = 0+2 = 2, T(4,3) = 6, T(4,4) = 24.
%e A321686 In case of n=5.
%e A321686             | p_1 1's, p_2 2's, | Arrangements satisfying
%e A321686   Partition |   ..., p_k k's    |      the condition
%e A321686   ----------+-------------------+---------------------------
%e A321686   5         |             11111 |
%e A321686   4+1       |             11112 |
%e A321686   3+2       |             11122 | 12121.
%e A321686   3+1+1     |             11123 | 12131, 13121.
%e A321686   2+2+1     |             11223 | 12123, 12132, 12312,
%e A321686             |                   | 12321, 13212, 31212,
%e A321686             |                   | 21213, 21231, 21321,
%e A321686             |                   | 21312, 23121, 32121.
%e A321686   2+1+1+1   |             11234 | 12134, 12143, ... ( 36 terms)
%e A321686   1+1+1+1+1 |             12345 | 12345, 12354, ... (120 terms)
%e A321686   So T(5,1) = 0, T(5,2) = 0+1 = 1, T(5,3) = 2+12 = 14, T(5,4) = 36, T(5,5) = 120.
%e A321686 Triangle begins:
%e A321686   1;
%e A321686   0, 2;
%e A321686   0, 1,   6;
%e A321686   0, 2,   6,   24;
%e A321686   0, 1,  14,   36,   120;
%e A321686   0, 2,  40,  108,   240,   720;
%e A321686   0, 1,  59,  348,   900,  1800,  5040;
%e A321686   0, 2, 112, 1486,  3300,  8160, 15120,  40320;
%e A321686   0, 1, 287, 3056, 15744, 33960, 80640, 141120, 362880;
%o A321686 (Ruby)
%o A321686 def partition(n, min, max)
%o A321686   return [[]] if n == 0
%o A321686   [max, n].min.downto(min).flat_map{|i| partition(n - i, min, i).map{|rest| [i, *rest]}}
%o A321686 end
%o A321686 def mul(f_ary, b_ary)
%o A321686   s1, s2 = f_ary.size, b_ary.size
%o A321686   ary = Array.new(s1 + s2 - 1, 0)
%o A321686   (0..s1 - 1).each{|i|
%o A321686     (0..s2 - 1).each{|j|
%o A321686       ary[i + j] += f_ary[i] * b_ary[j]
%o A321686     }
%o A321686   }
%o A321686   ary
%o A321686 end
%o A321686 def ncr(n, r)
%o A321686   return 1 if r == 0
%o A321686   (n - r + 1..n).inject(:*) / (1..r).inject(:*)
%o A321686 end
%o A321686 def f(n)
%o A321686   return 1 if n < 2
%o A321686   (1..n).inject(:*)
%o A321686 end
%o A321686 def A(a)
%o A321686   ary = [1]
%o A321686   a.each{|i|
%o A321686     ary = mul(ary, [0] + (1..i).map{|j| (-1) ** (i - j) * ncr(i - 1, i - j) / f(j).to_r})
%o A321686   }
%o A321686   (0..ary.size - 1).inject(0){|s, i| s + f(i) * ary[i]}.to_i
%o A321686 end
%o A321686 def A321686(n)
%o A321686   a = Array.new(n + 1, 0)
%o A321686   partition(n, 1, n).each{|ary|
%o A321686     a[ary.size] += A(ary)
%o A321686   }
%o A321686   a[1..-1]
%o A321686 end
%o A321686 (1..15).each{|i| p A321686(i)}
%Y A321686 Row sums: A321688.
%Y A321686 Cf. A000041, A000142, A008277.
%K A321686 nonn,tabl
%O A321686 1,3
%A A321686 _Seiichi Manyama_, Nov 17 2018