Z21135

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z21135"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z16431",
        "Z14K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z600",
            "Z16K2": "function Z16431( Z16431K1 ) {\n\tconst input_value=Z16431K1;\n\tconst ones = [\"\", \"uno\", \"dos\", \"tres\", \"cuatro\", \"cinco\", \"seis\", \"siete\", \"ocho\", \"nueve\", \"diez\", \"once\", \"doce\", \"trece\", \"catorce\", \"quince\", \"dieciséis\", \"diecisiete\", \"dieciocho\", \"diecinueve\", \"veinte\", \"veintiuno\", \"veintidós\", \"veintitrés\", \"veinticuatro\", \"veinticinco\", \"veintiséis\", \"veintisiete\", \"veintiocho\", \"veintinueve\"];\n\tconst tens = [\"\", \"\", \"\", \"treinta\", \"cuarenta\", \"cincuenta\", \"sesenta\", \"setenta\", \"ochenta\", \"noventa\"];\n\tconst hundreds = [\"\", \"ciento\", \"doscientos\", \"trescientos\", \"cuatrocientos\", \"quinientos\", \"seiscientos\", \"setecientos\", \"ochocientos\", \"novecientos\"];\n\tconst units = [\"nonillón\", \"octillón\", \"septillón\", \"sextillón\", \"quintillón\", \"cuatrillón\", \"trillón\", \"billón\", \"millón\", \"\"];\n\tconst values = [10n ** 54n, 10n ** 48n, 10n ** 42n, 10n ** 36n, 10n ** 30n, 10n ** 24n, 10n ** 18n, 10n ** 12n, 10n ** 6n, 1n];\n\n\tconst words = (n) =\u003E {\n\t\tif (n \u003C= 29) {\n\t\t\treturn ones[n];\n\t\t} else if (n \u003C= 99) {\n\t\t\tconst tens_unit = tens[Math.floor(n / 10)];\n\t\t\tconst ones_unit = ones[n % 10];\n\t\t\treturn n % 10 ? tens_unit + \" y \" + ones_unit : tens_unit;\n\t\t} else if (n \u003C= 999) {\n\t\t\tconst hundreds_unit = hundreds[Math.floor(n / 100)];\n\t\t\tif (n === 100) {\n\t\t\t\treturn \"cien\";\n\t\t\t} else {\n\t\t\t\treturn n % 100 ? hundreds_unit + \" \" + words(n % 100) : hundreds_unit;\n\t\t\t}\n\t\t} else {\n\t\t\tif (Math.floor(n / 1000) === 1) {\n\t\t\t\treturn \"mil \" + words(n % 1000);\n\t\t\t} else {\n\t\t\t\tconst thousands = Math.floor(n / 1000);\n\t\t\t\tlet prefix = words(thousands);\n\t\t\t\tif (thousands % 10 === 1 \u0026\u0026 thousands % 100 !== 11) {\n\t\t\t\t\tprefix = prefix.substring(0, prefix.length - 1);\n\t\t\t\t}\n\t\t\t\tif (thousands % 100 === 21) {\n\t\t\t\t\tprefix = prefix.substring(0, prefix.length - 2) + \"ún\";\n\t\t\t\t}\n\t\t\t\treturn prefix + \" mil \" + words(n % 1000);\n\t\t\t}\n\t\t}\n\t};\n\t\n\t// convert numbers to words\n\tif (Z16431K1 === 0n) {\n\t\treturn \"cero\";\n\t}\n\tlet result = \"\";\n\tunits.forEach((unit_name, i) =\u003E {\n\t\tconst factor = values[i];\n\t\tconst count = Number(BigInt(Z16431K1) / BigInt(factor));\n\t\tZ16431K1 = BigInt(Z16431K1) % factor;\n\t\tif (count \u003E 999999) {\n\t\t\tWikifunctions.Error(\"Z28307\",[String(input_value),\"999999999999999999999999999999999999999999999999999999999999\",\"es\"]);\n\t\t}\n\t\tlet prefix = words(count);\n\t\tif (factor !== 1n) {\n\t\t\tunit_name = count \u003E 1 ? unit_name.substring(0, unit_name.length - 2) + \"ones\" : unit_name;\n\t\t\t// drop -o in uno and vientiuno before units\n\t\t\tif (count % 10 === 1 \u0026\u0026 count % 100 !== 11) {\n\t\t\t\tprefix = prefix.substring(0, prefix.length - 1);\n\t\t\t}\n\t\t\tif (count % 100 === 21) {\n\t\t\t\tprefix = prefix.substring(0, prefix.length - 2) + \"ún\";\n\t\t\t}\n\t\t}\n\t\tif (count \u003E 0) {\n\t\t\tresult = result + \" \" + prefix + \" \" + unit_name;\n\t\t}\n\t});\n\treturn result.trim();\n}"
        }
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "Spanish cardinal, JS"
            },
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1004",
                "Z11K2": "cardinal en espagnol, en JavaScript"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "Javascript implementation of Spanish cardinal function"
            }
        ]
    }
}