Last active
January 19, 2020 13:51
-
-
Save Diapolo10/f629200277e705e6afd837b304a120a7 to your computer and use it in GitHub Desktop.
A general solution for the four fours problem
This file contains 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
# log(log(sqrt(4), 4), (sqrt(4)/4)) == 1 | |
import math | |
def repeat(func, n): | |
x = 4 | |
for _ in range(n): | |
x = func(x) | |
return x | |
def four_fours(n): | |
inner = repeat(math.sqrt, n) | |
return round(math.log(math.log(inner, 4), (math.sqrt(4)/4))) | |
if __name__ == '__main__': | |
print("The four fours problem, first 100 solutions:") | |
subscript_digits = '₀₁₂₃₄₅₆₇₈₉' | |
print("Format: number, equation, calculated number") | |
for num in range(100): | |
inner = f"{'√' * num}4" | |
print(f"{num} = log₄(log√₄/₄({inner})) = {four_fours(num)}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment