login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A235049 Subtract one from each nonzero digit in decimal representation of n. 3

%I #23 Jan 13 2023 11:05:01

%S 0,0,1,2,3,4,5,6,7,8,0,0,1,2,3,4,5,6,7,8,10,10,11,12,13,14,15,16,17,

%T 18,20,20,21,22,23,24,25,26,27,28,30,30,31,32,33,34,35,36,37,38,40,40,

%U 41,42,43,44,45,46,47,48,50,50,51,52,53,54,55,56,57,58,60

%N Subtract one from each nonzero digit in decimal representation of n.

%C Contains exactly the same terms as A007095, except that each occurs an infinite number of times.

%C A102683(a(n)) = 0. - _Reinhard Zumkeller_, Apr 16 2014

%H Antti Karttunen, <a href="/A235049/b235049.txt">Table of n, a(n) for n = 0..10000</a>

%H <a href="/index/De#decimal_expansion">Index entries for sequences related to decimal expansion of n</a>

%F 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.

%e 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.

%t a[n_] := FromDigits[If[#>0, #-1, #]& /@ IntegerDigits[n]];

%t Table[a[n], {n, 0, 100}] (* _Jean-François Alcover_, Jan 13 2023 *)

%o (MIT/GNU Scheme, two implementations)

%o (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)))))))

%o ;; As a recurrence, using memoization macro definec from _Antti Karttunen_'s IntSeq-library:

%o (definec (A235049 n) (if (zero? n) n (let ((d (modulo n 10))) (+ (* 10 (A235049 (floor->exact (/ n 10)))) (if (zero? d) d (- d 1))))))

%o (Haskell)

%o a235049 x = if x == 0 then 0 else 10 * a235049 x' + max 0 (d - 1)

%o where (x', d) = divMod x 10

%o -- _Reinhard Zumkeller_, Apr 16 2014

%Y Cf. A007095.

%K nonn,easy,base,look

%O 0,4

%A _Antti Karttunen_, Apr 14 2014

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 16 00:00 EDT 2024. Contains 371696 sequences. (Running on oeis4.)