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.

A055120 Digital complement of n (replace each nonzero digit d with 10-d).

This page as a plain text file.
%I A055120 #61 Jan 16 2023 11:17:26
%S A055120 0,9,8,7,6,5,4,3,2,1,90,99,98,97,96,95,94,93,92,91,80,89,88,87,86,85,
%T A055120 84,83,82,81,70,79,78,77,76,75,74,73,72,71,60,69,68,67,66,65,64,63,62,
%U A055120 61,50,59,58,57,56,55,54,53,52,51,40,49,48,47,46,45,44,43,42,41,30,39
%N A055120 Digital complement of n (replace each nonzero digit d with 10-d).
%C A055120 a(n) = -n in carryless arithmetic mod 10 - that is, n + a(n) = 0 (cf. A169894). - _N. J. A. Sloane_, Aug 03 2010
%H A055120 N. J. A. Sloane, <a href="/A055120/b055120.txt">Table of n, a(n) for n = 0..10000</a>
%H A055120 David Applegate, Marc LeBrun and N. J. A. Sloane, <a href="http://neilsloane.com/doc/carry1.pdf">Carryless Arithmetic (I): The Mod 10 Version</a>.
%H A055120 <a href="/index/Ca#CARRYLESS">Index entries for sequences related to carryless arithmetic</a>
%H A055120 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F A055120 From _Robert Israel_, Sep 04 2017: (Start)
%F A055120 a(10*n) = 10*a(n).
%F A055120 a(10*n+j) = 10*a(n) + 10 - j for 1 <= j <= 9.
%F A055120 G.f. g(x) satisfies g(x) = 10*(1+x+x^2+...+x^9)*g(x^10) + (9*x+8*x^2+7*x^3+6*x^4+5*x^5+4*x^6+3*x^7+2*x^8+x^9)/(1-x^10).
%F A055120 (End)
%e A055120 a(11) = 99 because 1 + 9 = 0 mod 10 for each digit.
%e A055120 a(20) = 80 because 2 + 8 = 0 mod 10 and 0 + 0 = 0 mod 10.
%p A055120 f:=proc(n) local t0,t1,i;
%p A055120 t0:=0; t1:=convert(n,base,10);
%p A055120 for i from 1 to nops(t1) do
%p A055120 if t1[i]>0 then t0:=t0+(10-t1[i])*10^(i-1); fi;
%p A055120 od:
%p A055120 RETURN(t0);
%p A055120 end;
%p A055120 # _N. J. A. Sloane_, Jan 21 2011
%t A055120 a[n_] := FromDigits[ IntegerDigits[n] /. d_?Positive -> 10-d]; Table[a[n], {n, 0, 100}](* _Jean-François Alcover_, Nov 28 2011 *)
%o A055120 (Haskell)
%o A055120 a055120 = foldl f 0 . reverse . unfoldr g where
%o A055120    f v d = if d == 0 then 10 * v else 10 * v + 10 - d
%o A055120    g x = if x == 0 then Nothing else Just $ swap $ divMod x 10
%o A055120 -- _Reinhard Zumkeller_, Oct 04 2011
%o A055120 (PARI) a(n)=fromdigits(apply(d->if(d,10-d,0),digits(n))) \\ _Charles R Greathouse IV_, Feb 08 2017
%o A055120 (Python)
%o A055120 def A055120(n): return int(''.join(str(10-int(d)) if d != '0' else d for d in str(n))) # _Chai Wah Wu_, Apr 03 2021
%Y A055120 Cf. A004488, A048647, A055115-A055126, A061601.
%Y A055120 Column k=10 of A248813.
%K A055120 base,easy,nice,nonn
%O A055120 0,2
%A A055120 _Henry Bottomley_, Apr 19 2000