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.
%I A124807 #20 Apr 30 2025 14:09:07 %S A124807 1,6,24,84,332,1336,5478,22658,94196,392664,1639274,6849002,28627874, %T A124807 119688094,500456806,2092720174,8751273556,36596513060,153042707976, %U A124807 640011807436,2676483843602,11192882945426,46807955443900 %N A124807 Number of base-6 circular n-digit numbers with adjacent digits differing by 2 or less. %C A124807 [Empirical] a(base,n) = a(base-1,n) + A005191(n+1) for base >= 2*floor(n/2) + 1. %H A124807 G. C. Greubel, <a href="/A124807/b124807.txt">Table of n, a(n) for n = 0..1000</a> %H A124807 OEIS Wiki, <a href="/wiki/Number_of_base_k_circular_n-digit_numbers_with_adjacent_digits_differing_by_d_or_less">Number of base k circular n-digit numbers with adjacent digits differing by d or less</a> %H A124807 <a href="/index/Rec#order_06">Index entries for linear recurrences with constant coefficients</a>, signature (6,-6,-8,5,2,-1). %F A124807 From _Colin Barker_, Jun 04 2017: (Start) %F A124807 G.f.: (1 - 6*x^2 - 16*x^3 + 15*x^4 + 8*x^5 - 5*x^6) / ((1 - 4*x - x^2 + x^3)*(1 - 2*x - x^2 + x^3)). %F A124807 a(n) = 6*a(n-1) - 6*a(n-2) - 8*a(n-3) + 5*a(n-4) + 2*a(n-5) - a(n-6) for n > 6. %F A124807 (End) %F A124807 a(n) = -5*[n=0] + 3*A006054(n+2) - 4*A006054(n+1) - A006054(n) + 3*A364705(n) - 8*A364705(n-1) - A364705(n-2). - _G. C. Greubel_, Aug 04 2023 %t A124807 LinearRecurrence[{6,-6,-8,5,2,-1}, {1,6,24,84,332,1336,5478}, 35] (* _G. C. Greubel_, Aug 04 2023 *) %o A124807 (S/R) stvar $[N]:(0..M-1) init $[]:=0 asgn $[]->{*} kill +[i in 0..N-1](($[i]`-$[(i+1)mod N]`>2)+($[(i+1)mod N]`-$[i]`>2)) %o A124807 (Magma) I:=[1,6,24,84,332,1336,5478]; [n le 7 select I[n] else 6*Self(n-1) -6*Self(n-2) -8*Self(n-3) +5*Self(n-4) +2*Self(n-5) -Self(n-6): n in [1..41]]; // _G. C. Greubel_, Aug 04 2023 %o A124807 (SageMath) %o A124807 @CachedFunction %o A124807 def a(n): # a = A124807 %o A124807 if (n<7): return (1,6,24,84,332,1336,5478)[n] %o A124807 else: return 6*a(n-1) -6*a(n-2) -8*a(n-3) +5*a(n-4) +2*a(n-5) -a(n-6) %o A124807 [a(n) for n in range(41)] # _G. C. Greubel_, Aug 04 2023 %Y A124807 Cf. A005191, A006054, A364705. %K A124807 nonn,easy %O A124807 0,2 %A A124807 _R. H. Hardin_, Dec 28 2006