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.
%I A328018 #29 Jul 10 2025 10:59:33 %S A328018 1,2,3,4,5,6,1,8,9,10,11,12,13,2,15,16,3,18,19,20,4,22,23,24,25,26,5, %T A328018 6,29,30,31,32,33,34,1,36,8,38,39,40,41,9,43,44,45,46,10,48,11,50,51, %U A328018 52,53,54,55,12,13,58,59,60,61,62,2,64,65,66,15,68,69,16,3 %N A328018 If n is the k-th number divisible by 7 or containing a digit 7 (in base 10) then a(n) = a(k) otherwise a(n) = n. %H A328018 David A. Corneth, <a href="/A328018/b328018.txt">Table of n, a(n) for n = 1..10000</a> %H A328018 David A. Corneth, <a href="/A328018/a328018.gp.txt">Pari Program</a> %e A328018 Let F be the sequence of integers divisible by 7 or containing a digit 7 (A092433) with offset 1. %e A328018 Sequence starts with the positive integers S. %e A328018 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, ... %e A328018 Replace all integers in S that are also in F with the index of occurrence in F. Doing this gives: %e A328018 1, 2, 3, 4, 5, 6, 1, 8, 9, 10, 11, 12, 13, 2, 15, 16, 3, 18, 19, 20, 4, 22, 23, 24, 25, 26, 5, 6, 29, 30, 31, 32, 33, 34, 7, 36, 8, 38, 39, 40, ... %e A328018 At position 35, we see 7, which is the first element in F so we replace this 7 with 1. This gives: %e A328018 1, 2, 3, 4, 5, 6, 1, 8, 9, 10, 11, 12, 13, 2, 15, 16, 3, 18, 19, 20, 4, 22, 23, 24, 25, 26, 5, 6, 29, 30, 31, 32, 33, 34, 1, 36, 8, 38, 39, 40, ... %e A328018 Keep replacing numbers in S that are also in F with the index of occurrence they have in F. That is: if s in S is F(i) then set replace s with i. %t A328018 Block[{nn = 70, s}, s = Select[Range[nn], Or[Mod[#, 7] == 0, DigitCount[#, 10, 7] > 0] &]; Array[If[FreeQ[s, #], #, FirstPosition[s, #][[1]] ] &, nn]] (* _Michael De Vlieger_, Oct 17 2019 *) %o A328018 (PARI) See Corneth link %o A328018 (PARI) k=0; for (n=1, #(a=vector(71)), print1 (a[n]=if (n%7==0 || setsearch(Set(digits(n)),7), a[k++], n) ", ")) \\ _Rémy Sigrist_, Nov 11 2019 %o A328018 (Python) %o A328018 def first(n): %o A328018 t = [] %o A328018 q = 0 %o A328018 for i in range(1, n+1): %o A328018 if i % 7 == 0 or "7" in str(i): %o A328018 q += 1 %o A328018 t.append(t[q-1]) %o A328018 else: %o A328018 t.append(i) %o A328018 return(t) # _David A. Corneth_, Jul 10 2025 %Y A328018 Cf. A092433. %K A328018 nonn,base,easy %O A328018 1,2 %A A328018 Rens Reus and _David A. Corneth_, Oct 01 2019