login
Delete all 5's from the sequence of nonnegative integers.
10

%I #39 Apr 22 2021 22:09:13

%S 0,1,2,3,4,6,7,8,9,10,11,12,13,14,1,16,17,18,19,20,21,22,23,24,2,26,

%T 27,28,29,30,31,32,33,34,3,36,37,38,39,40,41,42,43,44,4,46,47,48,49,0,

%U 1,2,3,4,6,7,8,9,60,61,62,63,64,6,66,67,68,69,70,71,72,73,74,7,76

%N Delete all 5's from the sequence of nonnegative integers.

%C In contrast to the variant A004180 where a(n) = 0 when all the digits of n are 5's, here a number completely disappears in that case, so that subsequent indices are shifted and for n > 4, a(n) is not the result of deleting 5's from n: see formula. - _M. F. Hasler_, Jan 13 2020

%F a(n) = A004180(n + m) where m = L(n) - [ (10^L(n)-1)/9*5 >= n + L(n) ], L(n) = floor(log_10(max(n,1)) + 1), the number of digits of n, and [...] is the Iverson bracket (1 if true, 0 else). - _M. F. Hasler_, Jan 13 2020

%e From _M. F. Hasler_, Jan 13 2020: (Start)

%e After a(4) = 4 comes a(5) = 6, since the number 5 completely disappears.

%e a(48) = 49 is followed by 0, 1, 2, 3, 4 (i.e., 50, ..., 54 with the initial digit removed) and then a(54) = 6, because 55 disappears completely.

%e Illustration of the formula: as long as n < 5 (the first number that completely disappears) we have a(n) = A004180(n). Here n has 1 digit but n+1 does not exceed the (single repdigit) 5 (left hand side in the Iverson bracket), so m = 0. From n = 5 on, n+1 > 5, so m = 1.

%e Then, when n has L(n) = 2 digits, we still have n = 2 - 1 = 1 as long as n+2 <= 55 or n <= 53, but m = 3 for n > 55 - 2 = 53, i.e., from n = 54 on (where the term 55 has disappeared, see above).

%e Similarly, m = 3 for n > 555 - 3, i.e., from n >= 553 on, etc. (End)

%o (PARI)

%o apply( {A004724(n,L=logint(n+!n,10)+1)=A004180(n+L-(10^L\9*5-L>=n))}, [0..99])

%o A004724_upto(N)={[fromdigits(v)|v<-[[d|d<-digits(n+!n*50),d!=5]|n<-[0..N]],#v]} \\ _M. F. Hasler_, Jan 13 2020

%o (MATLAB) m=1; for u=0:76 v=dec2base(u, 10)-'0'; v = v(v~=5); if length(v)>0; sol(m)=(str2num(strrep(num2str(v), ' ', ''))); m=m+1; end; end; sol % _Marius A. Burtea_, Jan 16 2020

%o (Python)

%o def A004724(n):

%o l = len(str(n))

%o m = 5*(10**l-1)//9

%o k = n + l - int(n+l < m)

%o return 4 if k == m else int(str(k).replace('5','')) # _Chai Wah Wu_, Apr 20 2021

%Y Cf. A004180 (delete digits 5 in n), A052413 (numbers with no digit 5).

%Y Cf. A004719, A004720, A004721, A004722, A004723, A004725, A004726, A004727, A004728.

%K base,nonn

%O 0,3

%A _N. J. A. Sloane_