You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
445 B
21 lines
445 B
def log_base_10(n):
|
|
if n == 0:
|
|
return float('-inf') # Logarithm of 0 is undefined
|
|
count = 0
|
|
while n >= 1:
|
|
n /= 10
|
|
count += 1
|
|
return count
|
|
|
|
|
|
if __name__ == '__main__':
|
|
n = 102
|
|
out = 0
|
|
for i in range(1, n + 1):
|
|
power = (i // 10 + 1)
|
|
|
|
# print(i, i / 10, log_base_10(i), pow(10, log_base_10(i) - 1), pow(10, power))
|
|
out = out * pow(10, log_base_10(i)) + i
|
|
|
|
print(out)
|