Skip to content

Commit fc3f70a

Browse files
authored
Corrected the documentation errors and misspells.
1 parent 32e611f commit fc3f70a

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

project_euler/problem_686/sol1.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"""
22
Project Euler Problem 686: https://projecteuler.net/problem=686
33
4-
2**7 = 128 is the first power of two whose leading digits are "12".
5-
The next power of two whose leading digits are "12" is 2**80.
4+
2^7 = 128 is the first power of two whose leading digits are "12".
5+
The next power of two whose leading digits are "12" is 2^80.
66
77
Define p(L,n) to be the nth-smallest value of j such that
8-
the base 10 representation of 2**j begins with the digits of L.
8+
the base 10 representation of 2^j begins with the digits of L.
99
1010
So p(12, 1) = 7 and p(12, 2) = 80.
1111
@@ -24,8 +24,8 @@ def log_difference(number: int) -> float:
2424
large exponents is time consuming. Hence we use log to reduce compute time.
2525
2626
We can find out that the first power of 2 with starting digits 123 is 90.
27-
Computing 2**90 is time consuming.
28-
Hence we find log(2**90) = 90*log(2) = 27.092699609758302
27+
Computing 2^90 is time consuming.
28+
Hence we find log(2^90) = 90*log(2) = 27.092699609758302
2929
But we require only the decimal part to determine whether the power starts with 123.
3030
SO we just return the decimal part of the log product.
3131
Therefore we return 0.092699609758302
@@ -43,14 +43,12 @@ def log_difference(number: int) -> float:
4343
return difference
4444

4545

46-
# series = 90, 379, 575, 864, 1060, 1545, 1741, 2030, 2226, 2515
47-
4846

4947
def solution(number: int = 678910) -> int:
5048
"""
5149
This function calculates the power of two which is nth (n = number)
5250
smallest value of power of 2
53-
such that the starting digits of the 2**power is 123.
51+
such that the starting digits of the 2^power is 123.
5452
5553
For example the powers of 2 for which starting digits is 123 are:
5654
90, 379, 575, 864, 1060, 1545, 1741, 2030, 2226, 2515 and so on.
@@ -64,7 +62,7 @@ def solution(number: int = 678910) -> int:
6462
lowerbound = log(1.23), upperbound = log(1.24)
6563
because we need to find the powers that yield 123 as starting digits.
6664
67-
log(1.23) = 08990511143939792, log(1,24) = 09342168516223506.
65+
log(1.23) = 0.08990511143939792, log(1,24) = 0.09342168516223506.
6866
We use 1.23 and not 12.3 or 123, because log(1.23) yields only decimal value
6967
which is less than 1.
7068
log(12.3) will be same decimal vale but 1 added to it

0 commit comments

Comments
 (0)