login
Numbers whose parity matches only their least significant decimal digit.
1

%I #35 Sep 09 2024 12:27:09

%S 1,2,3,4,5,6,7,8,9,10,12,14,16,18,21,23,25,27,29,30,32,34,36,38,41,43,

%T 45,47,49,50,52,54,56,58,61,63,65,67,69,70,72,74,76,78,81,83,85,87,89,

%U 90,92,94,96,98,110,112,114,116,118,130,132,134,136,138

%N Numbers whose parity matches only their least significant decimal digit.

%C There are 9*5^(n-1) n-digit terms, hence a(n) << n^k with k = log 5/log 10 = 0.69897.... - _Charles R Greathouse IV_, May 12 2014

%H Robert Israel, <a href="/A242367/b242367.txt">Table of n, a(n) for n = 1..10000</a>

%e 100 is not in the sequence since 100 is even but has 2 even digits (both the second and third digits).

%e 998 is in the sequence since 998 is even and the only even digit is the final digit.

%p N:= 3: # for terms of up to N digits

%p fodd:= proc(t) local i; seq(10*t+i,i=1..9,2) end proc:

%p feven:= proc(t) local i; seq(10*t+i,i=0..8,2) end proc:

%p feven(0):= (2,4,6,8):

%p A[0]:= [0]:

%p B[0]:= [0]:

%p for d from 1 to N-1 do

%p A[d]:= map(feven, A[d-1]);

%p B[d]:= map(fodd, B[d-1]);

%p od:

%p R:= NULL:

%p for i from 0 to N-1 do

%p R:= R, op(map(fodd,A[i])),

%p op(map(feven,B[i]))

%p od:

%p sort([R]); # _Robert Israel_, Sep 09 2024

%o (Python)

%o def ok(n): return set(str(n)[:-1]) & set(["02468", "13579"][n&1]) == set()

%o print([k for k in range(1, 140) if ok(k)]) # _Michael S. Branicky_, Sep 09 2024

%K nonn,base,look

%O 1,2

%A _J. Lowell_, May 12 2014