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.

A359142 Let s = sum of digits of n, let t = decimal concatenation of n and s, let u be obtained by deleting all copies of the leading digit of t from t, if this digit occurs in s. Then if u has only zero digits, a(n) = 0; if u has leading digit 0 but not all its digits are 0, delete all leading 0's from u and negate the result to get a(n); otherwise a(n) = u.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 123, 134, 145, 156, 167, 178, 189, 90, 0, 213, 224, 235, 246, 257, 268, 279, 2810, 2911, 0, 314, 325, 336, 347, 358, 369, 3710, 3811, 3912, 0, 415, 426, 437, 448, 459, 4610, 4711, 4812, 4913, 0, 516, 527, 538, 549, 5510, 5611, 5712, 5813
Offset: 1

Views

Author

N. J. A. Sloane, Jan 31 2023, based on suggestions from Eric Angelini and Hans Havermann

Keywords

Comments

Since nonzero numbers may not have leading zeros, we indicate their presence by negating the number.
For use in A359142, we also define a(n) for improper decimal numbers n with leading zeros by following exactly the same steps. To get a(073), for example, we append the digit sum 10, and delete the 0's from 07310, getting a(073) = 731. To get a(074), we append 11, getting 07411, so a(074) = -7411.
The sequence of n such that a(n) < 0 begins (109, 1009, 1018, 1019, 1027, 1028, 1029, 1036, ...): see A359144. - M. F. Hasler, Feb 01 2023

Examples

			Examples:
  n.....s......t....u.....a(n)
  1.....1.....11....0......0
  2.....2.....22....0......0
  .....
  9.....9.....99....0......0
  10....1....101....0......0
  11....2....112..112....112
  12....3....123..123....123
  .....
  100...1...1001...00......0
  101...2...1012.1012...1012
  102...3...1023.1023...1023
  .....
  109..10..10910..090....-90
  .....
		

Crossrefs

Cf. A359143, A359144 (k such that a(k)<0).

Programs

  • Mathematica
    A359142[n_]:= Module[{d=IntegerDigits[n],s,u},If[MemberQ[s=IntegerDigits[Total[d]],First[u=Join[d,s]]],u=DeleteCases[u,First[u]]];If[u=={}||First[u]==0,-1,1]FromDigits[u]];Array[A359142,100] (* Paolo Xausa, Oct 11 2023 *)
  • PARI
    A359142(n) = { my(d=digits(n), s=digits(vecsum(d))); n>0 || d=concat(0,d); n=concat(d, s); setsearch(Set(s), d[1]) && n=select(c->c!=d[1], n); if(n && !n[1], -fromdigits(n), fromdigits(n)) }
    apply(A359142, [0..99]) \\ M. F. Hasler, Feb 01 2023
    
  • Python
    def a(n):
        n = str(-n) if isinstance(n, int) and n < 0 else str(n)
        s = str(sum(map(int, n)))
        t = n + s
        u = t.replace(t[0], "") if t[0] in s else t
        return 0 if u == "" else (-int(u) if u[0] == "0" else int(u))
    print([a(n) for n in range(1, 59)]) # Michael S. Branicky, Feb 01 2023

Extensions

More terms from M. F. Hasler, Feb 01 2023