A321801 Delete all consecutive identical decimal digits of n; write 0 if all digits disappear.
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 0, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 0, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 0, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 0, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 0, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 0, 1, 101, 102, 103, 104, 105, 106, 107, 108, 109, 0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 120, 121, 1, 123, 124, 125, 126, 127, 128, 129, 130, 131
Offset: 0
Examples
12311 becomes 123, 1123 becomes 23, 11231 becomes 231, and 110232 becomes 232 (as we don't accept leading zeros). Note that 112233 disappears immediately and we get 0. 1110, 11000, 1100011 all become 0.
Links
- Paolo Xausa, Table of n, a(n) for n = 0..10000
Programs
-
Mathematica
A321801[n_]:=FromDigits[Flatten[Select[Split[IntegerDigits[n]],Length[#]==1&]]];Array[A321801,100,0] (* Paolo Xausa, Nov 14 2023 *)
-
PARI
A321801(n)={forstep(i=#n=digits(n),2,-1,n[i]!=n[i-1]&&next;if(i<3||n[i-2]!=n[i],n=n[^i];i--);n=n[^i]);fromdigits(n)} \\ M. F. Hasler, Nov 20 2018
-
Python
from re import split def A321801(n): return int('0'+''.join(d if len(d) == 1 else '' for d in split('(0+)|(1+)|(2+)|(3+)|(4+)|(5+)|(6+)|(7+)|(8+)|(9+)',str(n)) if d != '' and d != None))
Comments