"This is certainly not the fastest or most clever solution for calculating digits of [Champernowne's constant](https://en.wikipedia.org/wiki/Champernowne_constant), but it's fast enough, and pretty comprehensible.\n",
"\n",
"Since there are so many strings to concatenate, for performance it is helpful to use the [`str.join` method](https://docs.python.org/3/library/stdtypes.html#str.join)."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "deed40a4",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"210"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from itertools import count\n",
"\n",
"c = '.' + ''.join(str(k) for k in range(1, 1_000_001))\n",
"prod(int(c[i]) for i in (1, 10, 100, 1000, 10000, 100000, 1000000))"
"* Digits of Champernowne's constant: [A033307](https://oeis.org/A033307)\n",
"\n",
"#### Copyright (C) 2025 filifa\n",
"\n",
"This work is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International license](https://creativecommons.org/licenses/by-sa/4.0/) and the [BSD Zero Clause license](https://spdx.org/licenses/0BSD.html)."