login
Number of numbers less than n, that are contained in n written as English number names.
3

%I #11 Feb 13 2024 08:13:48

%S 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,0,2,2,2,2,2,2,2,2,2,0,2,2,2,

%T 2,2,2,2,2,2,0,2,2,2,2,2,2,2,2,2,0,2,2,2,2,2,2,2,2,2,1,3,3,3,3,3,2,3,

%U 3,3,1,3,3,3,3,3,3,2,3,3,1,3,3,3,3,3,3,3,2,3,1,3,3,3,3,3,3,3,3,2,1,2,3,3,3

%N Number of numbers less than n, that are contained in n written as English number names.

%C a(A159452(n)) = 0;

%C a(A159453(n)) = n and a(m) <> n for m < A159453(n).

%H Reinhard Zumkeller, <a href="/A159451/b159451.txt">Table of n, a(n) for n = 0..10000</a>

%H Robert G. Wilson v, <a href="/A000027/a000027.txt">English names for the numbers from 0 to 11159 without spaces or hyphens</a>

%e n = 19 -> nineteen: a(19) = #{nine} = 1;

%e n = 20 -> twenty: a(20) = #{} = 0;

%e n = 21 -> twentyone: a(21) = #{one, twenty} = 2.

%o (Python)

%o from num2words import num2words

%o from functools import cache

%o @cache

%o def n2w(n):

%o map = {ord(c): None for c in "-, "}

%o return num2words(n).replace(" and", "").translate(map)

%o def a(n): wn = n2w(n); return sum(1 for i in range(n) if n2w(i) in wn)

%o print([a(n) for n in range(105)]) # _Michael S. Branicky_, Feb 13 2024

%Y Cf. A000027, A159452, A159453.

%K nonn,word

%O 0,22

%A _Reinhard Zumkeller_, Apr 12 2009