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.
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, 41, 9, 43, 44, 45, 46, 10, 48, 11, 50, 51, 52, 53, 54, 55, 12, 13, 58, 59, 60, 61, 62, 2, 64, 65, 66, 15, 68, 69, 16, 3
Offset: 1
Examples
Let F be the sequence of integers divisible by 7 or containing a digit 7 (A092433) with offset 1. Sequence starts with the positive integers S. 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, ... Replace all integers in S that are also in F with the index of occurrence in F. Doing this gives: 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, ... At position 35, we see 7, which is the first element in F so we replace this 7 with 1. This gives: 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, ... 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.
Links
- David A. Corneth, Table of n, a(n) for n = 1..10000
- David A. Corneth, Pari Program
Crossrefs
Cf. A092433.
Programs
-
Mathematica
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 *)
-
PARI
See Corneth link
-
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
-
Python
def first(n): t = [] q = 0 for i in range(1, n+1): if i % 7 == 0 or "7" in str(i): q += 1 t.append(t[q-1]) else: t.append(i) return(t) # David A. Corneth, Jul 10 2025