Champernowne's Constant¶
This is certainly not the fastest or most clever solution for calculating digits of Champernowne's constant, but it's fast enough, and pretty comprehensible.
Since there are so many strings to concatenate, for performance it is helpful to use the str.join method.
In [1]:
from itertools import count
c = '.' + ''.join(str(k) for k in range(1, 1_000_001))
prod(int(c[i]) for i in (1, 10, 100, 1000, 10000, 100000, 1000000))
Out[1]:
210
Relevant sequences¶
- Digits of Champernowne's constant: A033307
Copyright (C) 2025 filifa¶
This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license and the BSD Zero Clause license.