OFFSET
0,3
COMMENTS
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
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
EXAMPLE
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)
PROG
(PARI)
A004724_upto(N)={[fromdigits(v)|v<-[[d|d<-digits(n+!n*50), d!=5]|n<-[0..N]], #v]} \\ M. F. Hasler, Jan 13 2020
(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
(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
CROSSREFS
KEYWORD
base,nonn
AUTHOR
STATUS
approved