%I M3222 #57 Jul 06 2024 01:38:58
%S 4,4,4,4,4,4,5,6,4,4,4,3,5,8,8,8,8,8,8,8,7,13,14,14,14,14,15,16,14,14,
%T 7,13,14,14,14,14,15,16,14,14,7,13,14,14,14,14,15,16,14,14,7,13,14,14,
%U 14,14,15,16,14,14,7,13,14,14,14,14,15,16,14,14,7
%N Number of letters in German name of n.
%C Standard German orthography; a letter with an umlaut or ß is counted as a single letter: e.g., 30 maps to length("dreißig") = 7.
%C There are ambiguities from n=100 on, since both, "hundert" and "einhundert" are equally valid and common. The same applies for 1000 with "tausend" or "eintausend". - _M. F. Hasler_, Nov 03 2013
%C In contrast to English (A005589 vs A052360) and French (A007005 vs A167507), there are no spaces or other punctuation in German names for numbers, until 10^6 = "eine Million". - _M. F. Hasler_, Sep 20 2014
%C There also appears to be an ambiguity on whether there is an 's' in the middle of 101*10^3, "(ein)hundertein(s)tausend". - _M. F. Hasler_, Apr 08 2023
%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
%H Wikipedia, <a href="https://de.wiktionary.org/wiki/Wiktionary:Deutsch/%C3%9Cbersicht_der_Zahlen">Deutsch/Übersicht der Zahlen</a>.
%H <a href="/index/Lc#letters">Index entries for sequences related to number of letters in n</a>
%o (PARI) /* Because names with ä, ö, ü or ß can't be entered directly as a string in the GP interface, we use a separate list for the names, for efficiency and readability of the main function. Note that the default lexicographical order is that of ISO 8859-1 character codes ("z" < "ß" < "ä"). In applications where this is not suitable, the special characters below can be replaced, e.g., with "ae, oe, ue, ss" or "a, o, u, s". [_M. F. Hasler_, Jul 05 2024] */
%o {deutsch = ["eins", "zwei", "drei", "vier", Str("f"Strchr(252)"nf"), "sechs", "sieben", "acht", "neun", "zehn", "elf", Str("zw"Strchr(246)"lf"), "dreizehn", "vierzehn", Str("f"Strchr(252)"nfzehn"), "sechzehn", "siebzehn", "achtzehn", "neunzehn", "zwanzig", Str("drei"Strchr(223)"ig"), "vierzig", Str("f"Strchr(252)"nfzig"), "sechzig", "siebzig", "achtzig", "neunzig"]}
%o German(n, e="eins", power=0, name="")={ if(power /* internal helper function */
%o , n = divrem(n, power); Str(German(n[1], e) name, if(n[2], German(n[2]), ""))
%o , n < 20, if(n>1, deutsch[n], n, e, "null")
%o , n < 100, Str(if(n%10, Str(German(n%10, "ein") "und"), "") deutsch[n\10+18])
%o , n < 1000, German(n, "ein", 100, "hundert") \\ replace "ein" with "" to get
%o , n < 10^6, German(n, "ein", 1000, "tausend")\\ hundert/tausend without "ein-"
%o , my(t=3); while(n>=10^t, t+=3); German(n, "ein", 10^t-=3, strprintf(
%o if(n\10^t>1, " %sen", t%2, "e %se", "e %s") if(n%10^t, " ", ""),
%o Str(["M", "B", "Tr", "Quadr", "Quint", "Sext", "Sept", "Oct", "Non",
%o "Dez", "Undez" /* etc. */][t\6], "illi", ["on", "ard"][t%2+1])))
%o )} \\ updated Mar 03 2020, Apr 08 2023, Jul 05 2024
%o A007208 = n -> #German(n) \\ _M. F. Hasler_, Nov 01 2013
%o A007208(n) = vecsum([c>32|c<-Vecsmall(German(n))]) \\ To exclude spaces; irrelevant for n < 10^6. - _M. F. Hasler_, Jul 05 2024
%Y Cf. A005589 and A052360 (English analog).
%Y Cf. A007005 and A167507 (French analog).
%K nonn,word
%O 0,1
%A _N. J. A. Sloane_.
%E Corrected by Markus Stausberg (markus(AT)polomi.de), Aug 08 2004
%E Initial term a(0) = 4 = #"null" added by _M. F. Hasler_, Nov 01 2013