@@ -27,7 +27,7 @@ def log_difference(number: int) -> float:
27
27
Computing 2^90 is time consuming.
28
28
Hence we find log(2^90) = 90*log(2) = 27.092699609758302
29
29
But we require only the decimal part to determine whether the power starts with 123.
30
- SO we just return the decimal part of the log product.
30
+ So we just return the decimal part of the log product.
31
31
Therefore we return 0.092699609758302
32
32
33
33
>>> log_difference(90)
@@ -57,14 +57,14 @@ def solution(number: int = 678910) -> int:
57
57
58
58
So if number = 10, then solution returns 2515 as we observe from above series.
59
59
60
- Wwe will define a lowerbound and upperbound.
60
+ We will define a lowerbound and upperbound.
61
61
lowerbound = log(1.23), upperbound = log(1.24)
62
62
because we need to find the powers that yield 123 as starting digits.
63
63
64
64
log(1.23) = 0.08990511143939792, log(1,24) = 0.09342168516223506.
65
65
We use 1.23 and not 12.3 or 123, because log(1.23) yields only decimal value
66
66
which is less than 1.
67
- log(12.3) will be same decimal vale but 1 added to it
67
+ log(12.3) will be same decimal value but 1 added to it
68
68
which is log(12.3) = 1.093421685162235.
69
69
We observe that decimal value remains same no matter 1.23 or 12.3
70
70
Since we use the function log_difference(),
@@ -87,7 +87,7 @@ def solution(number: int = 678910) -> int:
87
87
Hence to optimize the algorithm we will increment by 196 or 93 depending upon the
88
88
log_difference() value.
89
89
90
- Lets take for example 90.
90
+ Let's take for example 90.
91
91
Since 90 is the first power leading to staring digits as 123,
92
92
we will increment iterator by 196.
93
93
Because the difference between any two powers leading to 123
@@ -99,15 +99,15 @@ def solution(number: int = 678910) -> int:
99
99
The iterator will now become 379,
100
100
which is the next power leading to 123 as starting digits.
101
101
102
- Lets take 1060. We increment by 196, we get 1256.
102
+ Let's take 1060. We increment by 196, we get 1256.
103
103
log_difference(1256) = 0.09367455396034,
104
104
Which is greater than upperbound hence we increment by 93. Now iterator is 1349.
105
105
log_difference(1349) = 0.08946415071057 which is less than lowerbound.
106
106
The next power is 1545 and we need to add 196 to get 1545.
107
107
108
108
Conditions are as follows:
109
109
110
- 1) If we find a power, whose log_difference() is in the range of
110
+ 1) If we find a power whose log_difference() is in the range of
111
111
lower and upperbound, we will increment by 196.
112
112
which implies that the power is a number which will lead to 123 as starting digits.
113
113
2) If we find a power, whose log_difference() is greater than or equal upperbound,
0 commit comments