login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A368477
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.
0
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, 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, 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
OFFSET
0,1
COMMENTS
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).
Sum_{i=0..10^k-1} a(10^k * n + i) = 10^k * a(n) for all n >= 0 and k >= 1.
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.
EXAMPLE
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.
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.
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.
PROG
(Python)
def a(n):
dp = [1] * 10
for c in str(n):
bdigit = int(c)
new_dp = [0] * 10
for j in range(10):
if bdigit != 0 and j + bdigit <= 9:
new_dp[j] += dp[j + bdigit]
if j - bdigit >= 0:
new_dp[j] += dp[j - bdigit]
dp = new_dp
return sum(dp)
CROSSREFS
Sequence in context: A337325 A156382 A214894 * A084487 A055567 A373994
KEYWORD
base,easy,nonn
AUTHOR
Shahrukh Jamil, Dec 26 2023
STATUS
approved