login
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.
3
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,2
EXAMPLE
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.
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 *)
PROG
(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) # See Reus link
CROSSREFS
Cf. A092433.
Sequence in context: A373028 A269165 A319655 * A242603 A106608 A255692
KEYWORD
nonn,base,easy
AUTHOR
Rens Reus and David A. Corneth, Oct 01 2019
STATUS
approved