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.

A383789 a(1) = 1; for n > 1, a(n) is the smallest positive integer not already in the sequence such that it shares at least one digit with a(n-1), and it has a different number of digits from a(n-1).

Original entry on oeis.org

1, 10, 100, 11, 101, 12, 2, 20, 102, 13, 3, 23, 103, 14, 4, 24, 104, 15, 5, 25, 105, 16, 6, 26, 106, 17, 7, 27, 107, 18, 8, 28, 108, 19, 9, 29, 109, 21, 110, 30, 113, 31, 111, 41, 112, 22, 120, 32, 121, 42, 114, 34, 123, 33, 130, 35, 115, 45, 124, 40, 134, 36, 116, 46, 126, 51, 117, 37, 127, 47, 137
Offset: 1

Views

Author

Ali Sada, May 09 2025

Keywords

Examples

			a(6) = 12, and 2 is the smallest number not already in the sequence that shares a digit with 12 and has a different number of digits. So, a(7) = 2.
		

Crossrefs

Programs

  • Magma
    function MySequence(N) a := [1]; while #a lt N do prev := a[#a]; d := Intseq(prev); m := #d; k := 2; repeat is_used := k in a; inter := &and[not x in d : x in Intseq(k)]; len_eq := #Intseq(k) eq m; k +:= 1; until not is_used and not inter and not len_eq; Append(~a, k - 1); end while; return a; end function; MySequence(100); // Vincenzo Librandi, May 17 2025
  • Mathematica
    a[1] = 1; a[n_] := a[n] = Module[{k = 2, s = Array[a, n-1], d = IntegerDigits[a[n-1]], m = IntegerLength[a[n-1]]}, While[! FreeQ[s, k] || Intersection[IntegerDigits[k], d] == {} || IntegerLength[k] == m, k++]; k]; Array[a, 100] (* Amiram Eldar, May 10 2025 *)
  • PARI
    isok(k, nbd, s, va) = if (#select(x->(x==k), va), return(0)); my(d=digits(k)); if (#setintersect(Set(d), s) && (#d != nbd), return(1));
    find(va, n) = my(k=2, d=digits(va[n-1]), nbd=#d, s=Set(d)); while (!isok(k, nbd, s, va), k++); k;
    lista(nn) = my(va = vector(nn)); va[1] = 1; for (n=2, nn, va[n] = find(va, n);); va; \\ Michel Marcus, May 13 2025