Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #52 Feb 20 2024 13:22:14
%S 10,18,16,14,12,10,8,6,4,2,18,34,30,26,22,18,14,10,6,2,16,30,28,24,20,
%T 16,12,8,4,2,14,26,24,22,18,14,10,6,4,2,12,22,20,18,16,12,8,6,4,2,10,
%U 18,16,14,12,10,8,6,4,2,8,14,12,10,8,8,8,6,4,2,6,10,8,6,6,6,6,6,4,2,4,6,4,4,4,4,4,4,4
%N a(n) is the number of integer tuples (b_1, b_2, ..., b_(k+1)) where 0 <= b_i <= 9, such that |b_i - b_(i+1)| = d_i for all i, where (d_1, d_2, ..., d_k) is the decimal expansion of n.
%C If n is (d_1, d_2, ..., d_(k-1), d_k) and m is (d_1, d_2, ..., d_(k-1), (10 - d_k) mod 10) then a(n) == a(m) (mod 4).
%C Sum_{i=0..10^k-1} a(10^k * n + i) = 10^k * a(n) for all n >= 0 and k >= 1.
%C Sum_{n=0..m * 10^k - 1} a(n) = 10^k * Sum_{n=0..m-1} a(n) for all m >= 1 and k >= 0.
%H Mathematics Stack Exchange, <a href="https://math.stackexchange.com/questions/4776466/some-questions-about-a-sequence-and-concepts-i-developed-to-find-its-nth-term">Discussion of concepts used to find nth term mathematically</a>.
%H Math subreddit, <a href="https://www.reddit.com/r/math/comments/18pxzat/generalised_the_integer_sequence_here_are_some/">Sequence mod 4 visualisation on a table</a>.
%e For n=0, there are 10 2-tuples (b_1, b_2) such that |b_1 - b_2| = 0; they are (0,0), (1,1), (2,2), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), so a(0)=10.
%e For n=1, there are 18 2-tuples (b_1, b_2) such that |b_1 - b_2| = 1; they are (0,1), (1,0), (1,2), (2,1), (2,3), (3,2), (3,4), (4,3), (4,5), (5,4), (5,6), (6,5), (6,7), (7,6), (7,8), (8,7), (8,9), (9,8), so a(1)=18.
%e For n=42, there are 20 3-tuples (b_1, b_2, b_3) such that |b_1 - b_2| = 4 and |b_2 - b_3| = 2; they are (0,4,2), (0,4,6), (1,5,3), (1,5,7), (2,6,4), (2,6,8), (3,7,9), (3,7,5), (4,0,2), (4,8,6), (5,1,3), (5,9,7), (6,2,0), (6,2,4), (7,3,1), (7,3,5), (8,4,2), (8,4,6), (9,5,3), (9,5,7), so a(42)=20.
%o (Python)
%o def a(n):
%o dp = [1] * 10
%o for c in str(n):
%o bdigit = int(c)
%o new_dp = [0] * 10
%o for j in range(10):
%o if bdigit != 0 and j + bdigit <= 9:
%o new_dp[j] += dp[j + bdigit]
%o if j - bdigit >= 0:
%o new_dp[j] += dp[j - bdigit]
%o dp = new_dp
%o return sum(dp)
%K base,easy,nonn
%O 0,1
%A _Shahrukh Jamil_, Dec 26 2023