Created
April 28, 2023 18:41
-
-
Save Aqendo/7c023807921898c38ffd4fe9f7880123 to your computer and use it in GitHub Desktop.
Code that can calculate almost infinity digits after comma. Works as-is, no comma sign, just a lot of numbers in a HUGE integer. Example: f(2) = 1414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641572
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
import sys | |
sys.set_int_max_str_digits(100000) | |
def square(number, amount_of_digits=100): | |
s = 1 | |
approximate = 0 | |
for i in range(amount_of_digits): | |
for z in range(1,number*10): | |
apr10 = approximate*10 | |
if (apr10+z)**2 > number * 10**((s-1)*2): | |
approximate = apr10 + z-1 | |
s += 1 | |
break | |
return approximate | |
print(square(2)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment