|
|
A297330
|
|
Total variation of base-10 digits of n; see Comments.
|
|
91
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 8, 7, 6, 5, 4, 3, 2
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,13
|
|
COMMENTS
|
Suppose that a number n has base-b digits b(m), b(m-1), ..., b(0). The base-b down-variation of n is the sum DV(n,b) of all d(i)-d(i-1) for which d(i) > d(i-1); the base-b up-variation of n is the sum UV(n,b) of all d(k-1)-d(k) for which d(k) < d(k-1). The total base-b variation of n is the sum TV(n,b) = DV(n,b) + UV(n,b). Guide to related sequences and partitions of the natural numbers:
***
Base b {DV(n,b)} {UV(n,b)} {TV(n,b)}
For each b, let u = {n : UV(n,b) < DV(n,b)}, e = {n : UV(n,b) = DV(n,b)}, and d = {n : UV(n,b) > DV(n,b)}. The sets u,e,d partition the natural numbers. A guide to the matching sequences for u, e, d follows:
***
Base b Sequence u Sequence e Sequence d
|
|
LINKS
|
|
|
EXAMPLE
|
13684632 has DV = 8-4 + 6-3 + 3-2 = 8 and has UV = 3-1 + 6-3 + 8-6 + 6-4 = 9, so that a(13684632) = DV + UV = 17.
|
|
MAPLE
|
f:= proc(n) local L, i; L:= convert(n, base, 10);
add(abs(L[i+1]-L[i]), i=1..nops(L)-1) end proc:
# alternative
|
|
MATHEMATICA
|
b = 10; z = 120; t = Table[Total@Flatten@Map[Abs@Differences@# &, Partition[ IntegerDigits[n, b], 2, 1]], {n, z}] (* after Michael De Vlieger, e.g. A037834 *)
|
|
PROG
|
(Python)
s = str(n)
return sum(abs(int(s[i])-int(s[i+1])) for i in range(len(s)-1)) # Chai Wah Wu, May 31 2022
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base,easy
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|