A004724 Delete all 5's from the sequence of nonnegative integers.
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, 27, 28, 29, 30, 31, 32, 33, 34, 3, 36, 37, 38, 39, 40, 41, 42, 43, 44, 4, 46, 47, 48, 49, 0, 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
Offset: 0
Examples
From _M. F. Hasler_, Jan 13 2020: (Start) After a(4) = 4 comes a(5) = 6, since the number 5 completely disappears. 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. 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. 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). Similarly, m = 3 for n > 555 - 3, i.e., from n >= 553 on, etc. (End)
Crossrefs
Programs
-
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
-
PARI
apply( {A004724(n,L=logint(n+!n,10)+1)=A004180(n+L-(10^L\9*5-L>=n))}, [0..99]) A004724_upto(N)={[fromdigits(v)|v<-[[d|d<-digits(n+!n*50),d!=5]|n<-[0..N]],#v]} \\ M. F. Hasler, Jan 13 2020
-
Python
def A004724(n): l = len(str(n)) m = 5*(10**l-1)//9 k = n + l - int(n+l < m) return 4 if k == m else int(str(k).replace('5','')) # Chai Wah Wu, Apr 20 2021
Formula
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
Comments