OFFSET
0,4
COMMENTS
Contains exactly the same terms as A007095, except that each occurs an infinite number of times.
A102683(a(n)) = 0. - Reinhard Zumkeller, Apr 16 2014
LINKS
FORMULA
a(0) = 0, and for n>=1, if n = 0 modulo 10, a(n) = 10*a(n/10), otherwise a(n) = 10*a(floor(n/10)) + (n modulo 10) - 1.
EXAMPLE
Subtracting one from each nonzero digit of '9', we get 8, thus a(9)=8. Doing same for '10' results '00' thus a(10)=0. For '12', this results '01', thus a(12)=1.
MATHEMATICA
a[n_] := FromDigits[If[#>0, #-1, #]& /@ IntegerDigits[n]];
Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Jan 13 2023 *)
PROG
(MIT/GNU Scheme, two implementations)
(define (A235049 n) (let loop ((z 0) (i 0) (n n)) (if (zero? n) z (let ((d (modulo n 10))) (loop (+ z (* (expt 10 i) (if (zero? d) d (- d 1)))) (1+ i) (floor->exact (/ n 10)))))))
;; As a recurrence, using memoization macro definec from Antti Karttunen's IntSeq-library:
(definec (A235049 n) (if (zero? n) n (let ((d (modulo n 10))) (+ (* 10 (A235049 (floor->exact (/ n 10)))) (if (zero? d) d (- d 1))))))
(Haskell)
a235049 x = if x == 0 then 0 else 10 * a235049 x' + max 0 (d - 1)
where (x', d) = divMod x 10
-- Reinhard Zumkeller, Apr 16 2014
CROSSREFS
KEYWORD
AUTHOR
Antti Karttunen, Apr 14 2014
STATUS
approved