File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change
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 ]))
You can’t perform that action at this time.
0 commit comments