cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A340671 #45 Jul 19 2024 11:15:02
%S A340671 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,
%T A340671 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,
%U A340671 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
%N 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.
%C A340671 Nonnegative integers can be used instead of positive integers, since zero will always be the last element alphabetically and will not change the sequence of the other integers.
%C A340671 This sequence uses standard US English names for numbers. "and" is not used, e.g., 101 is rendered as "one hundred one" rather than "one hundred and one".
%C A340671 a(n) is equivalent to the number of terms in the n-th row of A124172 for which the term in the k-th column is equal to k.
%C A340671 For n < 100, a(n) + 2 = a(200 + n). This is because a(200) = 2, and the numbers starting with "two hundred" will follow all of 1-199 alphabetically, so the range [201, 200 + n] will be in the same order as [1, n]. Similarly, because a(2000) = 4, for n < 999, a(n) + 4 = a(2000 + n). [Editor's note: It is unclear how the author finds a(2000) = 4. Both versions mentioned below give a(2000) = 2. - _M. F. Hasler_, Jul 05 2024]
%C A340671 From _Claudio Meller_, _Hans Havermann_ and _Michael S. Branicky_, Jul 03 2024: (Start)
%C A340671 A formalization of Philip Cohen's solution to "Alphabetizing the Integers" in (Eckler, p. 20).
%C A340671 When alphabetizing in the b-file and a-file, the space is assumed to precede any letter, so EIGHT HUNDRED comes before EIGHTEEN. No commas are used, but hyphens are used. (End)
%C A340671 At least two variants of this sequence are conceivable, depending on whether spaces and hyphens are considered or ignored, when sorting the English names of the numbers. If spaces are considered, "eight hundred" comes before "eighteen"; if they are ignored, "eighteen" comes only after all of "eight hundred ...". The two variants would not differ until a(815), where "eighteen" would be the only "fixed point" (i.e., listed at the 18th place) in the first variant, but not in the second variant (where it is listed in the 2nd place, after "eight"). - _M. F. Hasler_, Jul 05 2024
%H A340671 Michael S. Branicky and Hans Havermann, <a href="/A340671/b340671.txt">Table of n, a(n) for n = 1..10000</a>
%H A340671 Michael S. Branicky, <a href="/A340671/a340671.py.txt">Python program and utilities for A340671</a>
%H A340671 A. Ross Eckler, <a href="https://digitalcommons.butler.edu/cgi/viewcontent.cgi?article=2556&amp;context=wordways">Alphabetizing the Integers</a> (Word Ways, 1981, Vol. 14, No. 1, pp. 18-20).
%H A340671 Hans Havermann and Michael S. Branicky, <a href="/A340671/a340671_1.txt">n, Set of Fixed Points for n = 1..10000</a>
%e A340671 a(1) = 1 ({one}, the 1st term is 1);
%e A340671 a(2) = 2 ({one, two}, the 1st term is 1 and the 2nd term is 2);
%e A340671 a(3) = 1 ({one, three, two}, the 1st term is 1);
%e A340671 a(4) = 1 ({four, one, three, two}, the 3rd term is 3);
%e A340671 a(11) = a(12) = 2 (the 4th term is 4 and the 7th term is 7);
%e A340671 a(13) = 3 (the 4th term is 4, the 7th term is 7, and the 12th term is 12).
%o A340671 (Python)
%o A340671 from num2words import num2words
%o A340671 def a(n):
%o A340671     sorted_list = sorted([num2words(m) for m in range(1, n+1)])
%o A340671     return sum(m == num2words(sorted_list.index(m)+1) for m in sorted_list)
%o A340671 print([a(n) for n in range(1, 101)]) # [Note: this program retains the "and" and commas. - _Michael S. Branicky_, Jul 05 2024]
%o A340671 (Python) # see link for faster version
%o A340671 from bisect import insort
%o A340671 from num2words import num2words
%o A340671 from itertools import count, islice
%o A340671 def n2w(n): # remove " and" and commas
%o A340671     return num2words(n).replace(" and", "").replace(", ", " ")
%o A340671 def agen(): # generator of terms
%o A340671     names = [] # a sorted list
%o A340671     for n in count(1):
%o A340671         insort(names, (n2w(n), n-1))
%o A340671         fixed = [j+1 for j in range(n) if names[j][1] == j]
%o A340671         yield len(fixed) # use "yield fixed" for list of fixed points
%o A340671 print(list(islice(agen(), 87))) # Michael S. Branicky, Jul 05 2024
%o A340671 (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
%Y A340671 Cf. A124172, A005589, A004740.
%K A340671 nonn,word
%O A340671 1,2
%A A340671 _Mikhail Soumar_, Jan 15 2021