login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A064834 If n (in base 10) is d_1 d_2 ... d_k then a(n) = Sum_{i = 1..[k/2] } |d_i - d_{k-i+1}|. 11
0, 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, 1, 0, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 0, 1, 2, 3 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,14
COMMENTS
Might be called the Palindromic Deviation (or PD(n)) of n, since it measures how far n is from being a palindrome. - W. W. Kokko, Mar 13 2013
a(A002113(n)) = 0; a(A029742(n)) > 0; A136522(n) = A000007(a(n)). - Reinhard Zumkeller, Sep 18 2013
LINKS
EXAMPLE
a(456) = | 4 - 6 | = 2, a(4567) = | 4 - 7 | + | 5 - 6 | = 4.
MAPLE
f:=proc(n)
local t1, t2, i;
t1:=convert(n, base, 10);
t2:=nops(t1);
add( abs(t1[i]-t1[t2+1-i]), i=1..floor(t2/2) );
end;
[seq(f(n), n=0..120)]; # N. J. A. Sloane, Mar 24 2013
MATHEMATICA
f[n_] := (k = IntegerDigits[n]; l = Length[k]; Sum[ Abs[ k[[i]] - k[[l - i + 1]]], {i, 1, Floor[l/2] } ] ); Table[ f[n], {n, 0, 100} ]
PROG
(Haskell)
a064834 n = sum $ take (length nds `div` 2) $
map abs $ zipWith (-) nds $ reverse nds
where nds = a031298_row n
-- Reinhard Zumkeller, Sep 18 2013
(Python)
from sympy import floor, ceiling
def A064834(n):
x, y = str(n), 0
lx2 = len(x)/2
for a, b in zip(x[:floor(lx2)], x[:ceiling(lx2)-1:-1]):
y += abs(int(a)-int(b))
return y
# Chai Wah Wu, Aug 09 2014
CROSSREFS
Sequence in context: A037904 A070615 A040114 * A040163 A113608 A040115
KEYWORD
nonn,base,easy
AUTHOR
N. J. A. Sloane, Oct 25 2001
EXTENSIONS
More terms from Vladeta Jovovic, Matthew Conroy and Robert G. Wilson v, Oct 26 2001
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 05:19 EDT 2024. Contains 371782 sequences. (Running on oeis4.)