A340671 a(n) is the number of values m such that, if the first n positive integers are arranged in alphabetical order in US English, the m-th term in the order is equal to m.
1, 2, 1, 1, 0, 0, 0, 1, 0, 0, 2, 2, 3, 2, 0, 1, 0, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 3, 1, 2, 1, 2, 1, 2, 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 1, 0, 0, 1, 1, 2, 0, 1, 0, 1, 0
Offset: 1
Examples
a(1) = 1 ({one}, the 1st term is 1); a(2) = 2 ({one, two}, the 1st term is 1 and the 2nd term is 2); a(3) = 1 ({one, three, two}, the 1st term is 1); a(4) = 1 ({four, one, three, two}, the 3rd term is 3); a(11) = a(12) = 2 (the 4th term is 4 and the 7th term is 7); a(13) = 3 (the 4th term is 4, the 7th term is 7, and the 12th term is 12).
Links
- Michael S. Branicky and Hans Havermann, Table of n, a(n) for n = 1..10000
- Michael S. Branicky, Python program and utilities for A340671
- A. Ross Eckler, Alphabetizing the Integers (Word Ways, 1981, Vol. 14, No. 1, pp. 18-20).
- Hans Havermann and Michael S. Branicky, n, Set of Fixed Points for n = 1..10000
Programs
-
PARI
apply( {A340671(n, cf=English)=sum(i=1, #n=vecsort([1..n], x->cf(x), 1), n[i]==i)}, [1..99]) \\ See A052360 for English(). To get the "ignore spaces and hyphens" variant, use "CF(x)=[c|c<-Vecsmall(English(x)), c>64]" as 2nd optional argument. To get the list of fixed points, replace "sum(i=1,(...))" by "[i|i<-[1..(...)]". - M. F. Hasler, Jul 05 2024
-
Python
from num2words import num2words def a(n): sorted_list = sorted([num2words(m) for m in range(1, n+1)]) return sum(m == num2words(sorted_list.index(m)+1) for m in sorted_list) print([a(n) for n in range(1, 101)]) # [Note: this program retains the "and" and commas. - Michael S. Branicky, Jul 05 2024]
-
Python
# see link for faster version from bisect import insort from num2words import num2words from itertools import count, islice def n2w(n): # remove " and" and commas return num2words(n).replace(" and", "").replace(", ", " ") def agen(): # generator of terms names = [] # a sorted list for n in count(1): insort(names, (n2w(n), n-1)) fixed = [j+1 for j in range(n) if names[j][1] == j] yield len(fixed) # use "yield fixed" for list of fixed points print(list(islice(agen(), 87))) # Michael S. Branicky, Jul 05 2024
Comments