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.

A279214 Number of permutations sigma such that |sigma(i+1)-sigma(i)| >= 3 for 1 <= i <= n - 1 and |sigma(i+2)-sigma(i)| >= 3 for 1 <= i <= n - 2.

This page as a plain text file.
%I A279214 #79 Dec 02 2018 02:57:08
%S A279214 1,1,0,0,0,0,0,0,0,2,40,792,15374,281434,5089060,93082532,1743601076,
%T A279214 33694028152
%N A279214 Number of permutations sigma such that |sigma(i+1)-sigma(i)| >= 3 for 1 <= i <= n - 1 and |sigma(i+2)-sigma(i)| >= 3 for 1 <= i <= n - 2.
%C A279214 2 | a(n) for n > 1.
%e A279214 a(9) = 2: 369258147, 741852963.
%o A279214 (Ruby)
%o A279214 def check(d, a, i)
%o A279214   return true if i == 0
%o A279214   j = 1
%o A279214   d_max = [i, d - 1].min
%o A279214   while (a[i] - a[i - j]).abs >= d && j < d_max
%o A279214     j += 1
%o A279214   end
%o A279214   (a[i] - a[i - j]).abs >= d
%o A279214 end
%o A279214 def solve(d, len, a = [])
%o A279214   b = []
%o A279214   if a.size == len
%o A279214     b << a
%o A279214   else
%o A279214     (1..len).each{|m|
%o A279214       s = a.size
%o A279214       if s == 0 || (s > 0 && !a.include?(m))
%o A279214         if check(d, a + [m], s)
%o A279214           b += solve(d, len, a + [m])
%o A279214         end
%o A279214       end
%o A279214     }
%o A279214   end
%o A279214   b
%o A279214 end
%o A279214 def A279214(n)
%o A279214   (0..n).map{|i| solve(3, i).size}
%o A279214 end
%o A279214 p A279214(12)
%Y A279214 Cf. A002464 (|sigma(i+1)-sigma(i)| >= 2), A127697 (|sigma(i+1)-sigma(i)| >= 3).
%K A279214 nonn,more
%O A279214 0,10
%A A279214 _Seiichi Manyama_, Dec 17 2016
%E A279214 a(0)-a(2), a(15)-a(17) from _Alois P. Heinz_, Dec 01 2018