Last active
March 17, 2022 21:49
-
-
Save mfornet/331adaed0ef3fa78bc019aac19e48184 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for j in range(1, 100): | |
for i in range(1, 100): | |
b = i**j | |
b_s, i_s, j_s = map(str, (b, i, j)) | |
if b_s.startswith('1') and b_s.endswith(i_s + j_s): | |
x = b_s[1:-len(i_s + j_s)] | |
print(f"{b} = 1^{x} * {i}^{j}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def estimate_digit(a, b): | |
num_digits = 1 | |
start = 1. | |
for _ in range(b): | |
start *= a | |
while start > 10**6: | |
start /= 10 | |
num_digits += 1 | |
while start >= 10: | |
start /= 10 | |
num_digits += 1 | |
return int(start), num_digits | |
for a in range(1, 10000): | |
for b in range(1, 10000): | |
suffix = str(a) + str(b) | |
fin = pow(a, b, 10**len(suffix)) | |
if suffix == str(fin): | |
first_digit, num_digits = estimate_digit(a, b) | |
if first_digit == 1: | |
print(a, b, suffix, num_digits) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment