A005589 Number of letters in the US English name of n, excluding spaces and hyphens.
4, 3, 3, 5, 4, 4, 3, 5, 5, 4, 3, 6, 6, 8, 8, 7, 7, 9, 8, 8, 6, 9, 9, 11, 10, 10, 9, 11, 11, 10, 6, 9, 9, 11, 10, 10, 9, 11, 11, 10, 5, 8, 8, 10, 9, 9, 8, 10, 10, 9, 5, 8, 8, 10, 9, 9, 8, 10, 10, 9, 5, 8, 8, 10, 9, 9, 8, 10, 10, 9, 7, 10, 10, 12, 11, 11, 10, 12, 12, 11, 6, 9, 9, 11, 10, 10, 9, 11, 11, 10, 6, 9, 9, 11, 10, 10, 9, 11, 11, 10, 10, 13, 13, 15, 14, 14, 13, 15, 15, 14, 13, 16, 16, 18, 18, 17, 17, 19, 18, 18, 16
Offset: 0
Examples
Note that A052360(373373) = 64 whereas a(373373) = 56.
References
- Problems Drive, Eureka, 37 (1974), 8-11 and 33.
- N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
Links
- Ely Golden, Table of n, a(n) for n = 0..11159
- M. Beeler, R. W. Gosper and R. Schroeppel, Item 134, in Beeler, M., Gosper, R. W. and Schroeppel, R. HAKMEM. MIT AI Memo 239, Feb 29 1972.
- Eureka, Problems Drive, Eureka, 37 (1974), 8-11, 32-33, 24-27. (Annotated scanned copy)
- Ely Golden, Arbitrary precision number naming program in Java
- Mathematica Stack Exchange, How to express an integer number in English words?
- Landon Curt Noll, The English Name of a Number.
- Eric Weisstein's World of Mathematics, Number.
- Robert G. Wilson v, English names for the numbers from 0 to 11159 without spaces or hyphens.
- Index entries for sequences related to number of letters in n
Crossrefs
Programs
-
Mathematica
inWords[n_] := Module[{r, numNames = {"", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}, teenNames = {"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"}, tensNames = {"", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"}, decimals = {"", "thousand", "million", "billion", "trillion", "quadrillion", "quintillion", "sextillion", "septillion", "octillion", "nonillion", "decillion", "undecillion", "duodecillion", "tredecillion", "quattuordecillion", "quindecillion", "sexdecillion", "septendecillion", "octodecillion", "novemdecillion", "vigintillion", "unvigintillion", "duovigintillion", "trevigintillion", "quattuorvigintillion", "quinvigintillion", "sexvigintillion", "septenvigintillion", "octovigintillion", "novemvigintillion", "trigintillion", "untrigintillion", "duotrigintillion"}}, r = If[# != 0, numNames[[# + 1]] <> "hundred" (* <> If[#2 != 0||#3 != 0," and",""] *), ""] <> Switch[#2, 0, numNames[[#3 + 1]], 1, teenNames[[#3 + 1]], _, tensNames[[#2 + 1]] <> numNames[[#3 + 1]]] & @@@ (PadLeft[ FromDigits /@ Characters@ StringReverse@#, 3] & /@ StringCases[ StringReverse@ IntegerString@ n, RegularExpression["\\d{1,3}"]]); StringJoin@ Reverse@ MapThread[ If[# != "", StringJoin[##], ""] &, {r, Take[decimals, Length@ r]} ]]; (* modified for this sequence from what is presented in the link and good to 10^102 -1 *) f[n_] := StringLength@ inWords@ n; f[0] = 4; Array[f, 84, 0] (* Robert G. Wilson v, Nov 04 2007 and revised Mar 31 2015, small revision by Ivan Panchenko, Nov 10 2019 *) a[n_] := StringLength[ StringReplace[ IntegerName[n, "Words"], "," | " " | "\[Hyphen]" -> ""]]; a /@ Range[0, 83] (* Mma version >= 10, Giovanni Resta, Apr 10 2017 *)
-
PARI
A005589(n, t=[10^12, #"trillion", 10^9, #"billion", 10^6, #"million", 1000, #"thousand", 100, #"hundred"])={ n>99 && forstep( i=1, #t, 2, n
999 && error("n >= 10^",valuation(t[1],10)+3," requires extended 2nd argument"); return( A005589(n[1])+t[i+1]+if( n[2], A005589( n[2] )))); if( n<20, #(["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"][n+1]), #([ "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" ][n\10-1])+if( n%10, A005589(n%10)))} \\ Extension of 2nd arg to larger numbers is easy using the names listed in Mathematica section above. Only the string lengths are required, so it's easy to extend this list further without additional knowledge and without writing out the names. - M. F. Hasler, Jul 26 2011, minor edit on Jun 15 2021 -
Python
from num2words import num2words def a(n): x = num2words(n).replace(' and ', '') l = [chr(i) for i in range(97, 123)] return sum(1 for i in x if i in l) print([a(n) for n in range(101)]) # Indranil Ghosh, Jul 05 2017
Extensions
Corrected and extended by Larry Reeves (larryr(AT)acm.org) and Allan C. Wechsler, Mar 20 2000
Erroneous b-file deleted by N. J. A. Sloane, Sep 25 2008
More than the usual number of terms are shown in the DATA field to avoid confusion with A362123. - N. J. A. Sloane, Apr 20 2023
Comments