cp's OEIS Frontend

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.

A085927 a(n) is the digitwise absolute difference between the n-th palindrome and its 9's complement.

This page as a plain text file.
%I A085927 #19 Jul 24 2024 15:18:17
%S A085927 7,5,3,1,1,3,5,7,9,77,55,33,11,11,33,55,77,99,797,777,757,737,717,717,
%T A085927 737,757,777,797,595,575,555,535,515,515,535,555,575,595,393,373,353,
%U A085927 333,313,313,333,353,373,393,191,171,151,131,111,111,131,151,171,191
%N A085927 a(n) is the digitwise absolute difference between the n-th palindrome and its 9's complement.
%H A085927 Michael S. Branicky, <a href="/A085927/b085927.txt">Table of n, a(n) for n = 1..10000</a>
%e A085927 a(24) = 717 because A002113(24) = 151 and A061601(151) = 848. 8-1 = 7 and 5-4 = 1, thus 717.
%o A085927 (Python)
%o A085927 from sympy import isprime
%o A085927 from itertools import count, product
%o A085927 def f(s): return int("".join(str(abs(9 - 2*int(c))) for c in s))
%o A085927 def pals(base=10): # all (nonzero) palindromes as strings
%o A085927     digits = "".join(str(i) for i in range(base))
%o A085927     for d in count(1):
%o A085927         for p in product(digits, repeat=d//2):
%o A085927             if d > 1 and p[0] == "0": continue
%o A085927             left = "".join(p); right = left[::-1]
%o A085927             for mid in [[""], digits][d%2]:
%o A085927                 t = left + mid + right
%o A085927                 if t != '0': yield t
%o A085927 def aupton(nn): p = pals(); return [f(next(p)) for i in range(nn)]
%o A085927 print(aupton(58)) # _Michael S. Branicky_, Jul 05 2021
%o A085927 (Python)
%o A085927 def A085927(n):
%o A085927     y = 10*(x:=10**(len(str(n+1>>1))-1))
%o A085927     m = str((c:=n+1-x)*x+int(str(c)[-2::-1] or 0) if n+1<x+y else (c:=n+1-y)*y+int(str(c)[::-1] or 0))
%o A085927     return int(''.join('9753113579'[int(d)] for d in m)) # _Chai Wah Wu_, Jul 24 2024
%Y A085927 Cf. A002113, A061601.
%K A085927 base,easy,nonn
%O A085927 1,1
%A A085927 _Amarnath Murthy_ and _Jason Earls_, Jul 13 2003
%E A085927 Edited and extended by _David Wasserman_, Feb 11 2005