A positive integer n is a semi-1 number if exactly half of the integers from 1 through n contain the digit 1. For example, 16 is semi-1, because exactly 8 of the integers between 1
and 16 contain the digit 1:
{1, 10, 11, 12, 13, 14, 15, 16}.
Find the largest semi-1 number you can find!
The largest semi-1 number I can find is 1062880.
There is an upper limit on semi-1 numbers. The probability for an n-digit number to contain no 1s, is (0.9)^n.
ln(.5)/ln(.9) is about 6.6
(0.9)^6 ~ 0.531441
(0.9)^7 ~ 0.4782969
As numbers grow larger, the percent without a 1 goes below 50%. So the percent which include a 1 will be higher than 50%. From this argument it should be rare to find a semi-1 number more than 6 or 7 digits long.
2
16
24
160
270
272
1456
3398
3418
3420
3422
13120
44686
118096
674934
1062880
This is in oeis: A343839. According to oeis, this is a finite set and these 16 numbers are the entire set.
--------------
big = 10000000
yes = 0
no = 0
for n in range(1, big+1):
if '1' in str(n):
yes += 1
else:
no += 1
if 2*yes == n:
print(n)
|
Posted by Larry
on 2024-03-13 08:12:22 |