We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9ed60ba commit 6a8f1cfCopy full SHA for 6a8f1cf
Project Euler/Problem 40/sol1.py
@@ -0,0 +1,26 @@
1
+#-.- coding: latin-1 -.-
2
+from __future__ import print_function
3
+'''
4
+Champernowne's constant
5
+Problem 40
6
+An irrational decimal fraction is created by concatenating the positive integers:
7
+
8
+0.123456789101112131415161718192021...
9
10
+It can be seen that the 12th digit of the fractional part is 1.
11
12
+If dn represents the nth digit of the fractional part, find the value of the following expression.
13
14
+d1 × d10 × d100 × d1000 × d10000 × d100000 × d1000000
15
16
17
+constant = []
18
+i = 1
19
20
+while len(constant) < 1e6:
21
+ constant.append(str(i))
22
+ i += 1
23
24
+constant = ''.join(constant)
25
26
+print(int(constant[0])*int(constant[9])*int(constant[99])*int(constant[999])*int(constant[9999])*int(constant[99999])*int(constant[999999]))
0 commit comments