login
A325112
Integers k such that no nonzero subsequence of the decimal representation of k is divisible by 3.
5
1, 2, 4, 5, 7, 8, 10, 11, 14, 17, 20, 22, 25, 28, 40, 41, 44, 47, 50, 52, 55, 58, 70, 71, 74, 77, 80, 82, 85, 88, 100, 101, 104, 107, 110, 140, 170, 200, 202, 205, 208, 220, 250, 280, 400, 401, 404, 407, 410, 440, 470, 500, 502, 505, 508, 520, 550, 580, 700
OFFSET
1,2
COMMENTS
Integers whose decimal representation contains either just one nonzero digit, which is congruent to 1 or 2 (mod 3), or just two nonzero digits, which are either both == 1 (mod 3) or both == 2 (mod 3). - Robert Israel, Dec 25 2019
LINKS
Chai Wah Wu, Algorithms for complementary sequences, arXiv:2409.05844 [math.NT], 2024.
EXAMPLE
From David A. Corneth, Sep 09 2024: (Start) 404 is in the sequence as its nonzero digits are (4,4). The nonzero subsequences of digits are (), (4), (4,4) with respective sums 0, 4, 8. None of these subsequences have a sum that is divisible by 3.
4160 is not in the sequence as one of its nonzero subsequences is (6) which sums to 6. As 6 is divisible by 3, 4160 is not in the sequence. (End)
MAPLE
F:= proc(d) local i, j, k, g;
g:= [1, 2, 4, 5, 7, 8];
op(sort([seq(i*10^(d-1), i=g), seq(seq(seq(i*10^(d-1) + j*10^k, j = select(t -> (t-i) mod 3 = 0, g)), k=0..d-2), i=g)]));
end proc:
seq(F(d), d=1..4); # Robert Israel, Dec 25 2019
MATHEMATICA
With[{k = 3}, Select[Range@ 700, NoneTrue[DeleteCases[FromDigits /@ Rest@ Subsequences[IntegerDigits@ #], 0], Mod[#, k] == 0 &] &]] (* Michael De Vlieger, Mar 31 2019 *)
PROG
(Python)
from itertools import combinations
def A325112(n):
def bisection(f, kmin=0, kmax=1):
while f(kmax) > kmax: kmax <<= 1
while kmax-kmin > 1:
kmid = kmax+kmin>>1
if f(kmid) <= kmid:
kmax = kmid
else:
kmin = kmid
return kmax
def f(x):
c, l = 0, len(str(x))
for i in range(l):
k = 10**i
for j in (1, 2, 4, 5, 7, 8):
if j*k<=x:
c += 1
for a in combinations((10**i for i in range(l)), 2):
for b in ((1, 1), (1, 4), (1, 7), (2, 2), (2, 5), (2, 8), (4, 1), (4, 4), (4, 7), (5, 2), (5, 5), (5, 8), (7, 1), (7, 4), (7, 7), (8, 2), (8, 5), (8, 8)):
if a[0]*b[0]+a[1]*b[1] <= x:
c += 1
return n+x-c
return bisection(f, n, n) # Chai Wah Wu, Sep 10 2024
CROSSREFS
Cf. A014261 (for 2), A325113 (for 4), A261189 (for 5), A325114 (for 7).
A261188 is a subsequence.
A376045 is the complement.
Sequence in context: A213539 A190849 A277121 * A370277 A102338 A285401
KEYWORD
nonn,base
AUTHOR
STATUS
approved