Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
A357884
a(1)=0; if a(n-1) shares any digits with n-1, then a(n) = a(n-1) with all copies of digits from n-1 removed. Otherwise, a(n) = a(n-1) + (n-1).
1
0, 1, 3, 0, 4, 9, 15, 22, 30, 39, 49, 60, 72, 85, 99, 114, 4, 21, 2, 21, 1, 0, 22, 0, 24, 4, 30, 57, 85, 114, 144, 44, 76, 109, 143, 14, 50, 87, 7, 46, 6, 47, 7, 50, 94, 9, 55, 102, 150, 199, 249, 300, 352, 2, 56, 6, 0, 57, 7, 66, 0, 61, 1, 64, 0, 65, 5
OFFSET
1,3
COMMENTS
If n-1 contains all digits of a(n-1), then a(n) = 0.
EXAMPLE
n a(n)
-- ----
14 85
15 85 + 14 = 99
16 99 + 15 = 114
17 1's removed = 4
MATHEMATICA
a[0] = 0; a[n_] := a[n] = Module[{da = IntegerDigits[a[n - 1]], dn = IntegerDigits[n - 1]}, If[Intersection[da, dn] == {}, a[n - 1] + n - 1, FromDigits[Select[da, ! MemberQ[dn, #] &]]]]; Array[a, 100, 0] (* Amiram Eldar, Oct 21 2022 *)
PROG
(MATLAB)
function a = A357884( max_n )
a = 0;
for n = 2:max_n
sa = num2str(a(n-1));
s = intersect(sa, num2str(n-2));
if isempty(s)
a(n) = a(n-1)+(n-2);
else
sd = ['0' regexprep(sa, ['[' s ']'], '')];
a(n) = str2double(sd);
end
end
a = a(2:end);
end % Thomas Scheuerle, Oct 18 2022
(Python)
from itertools import count, islice
def A357884_gen(): # generator of terms
a, s = 0, '0'
for n in count(1):
yield a
if len(t:=set(s)&set(str(n))) > 0:
a = int(s.translate(s.maketrans('', '', ''.join(t))) or 0)
else:
a += n
s = str(a)
A357884_list = list(islice(A357884_gen(), 30)) # Chai Wah Wu, Oct 27 2022
CROSSREFS
Cf. A045541.
Sequence in context: A309764 A079406 A068627 * A074171 A180657 A375856
KEYWORD
nonn,base,easy,look
AUTHOR
Gavin Lupo, Oct 18 2022
STATUS
approved