Test / MathPro.py
Drbrain0620's picture
Upload folder using huggingface_hub
e3af2b1 verified
import time, sys
sys.set_int_max_str_digits(0)
st = int(input("start? "))
en = int(input("end? "))
se = int(input("step? "))
size = int(input("size? "))
xQ = input("show x values?(y/n) ")
with open('Result.txt', 'w', encoding='utf8') as f:
for S in range(st, en + 1, se):
MaxN = size
X = [[2, 1]]
AminB = []
for i in range(1, MaxN + 1):
Temp = [[X[i-1][0] ** 2, X[i-1][1] * X[i-1][0]], [X[i-1][1] * X[i-1][1] * S, X[i-1][1] * X[i-1][0]]]
if X[i-1][1] == 1 and (int(Temp[1][0] / 2) == Temp[1][0] / 2 and int(Temp[1][1] / 2) == Temp[1][1] / 2 and int(Temp[0][0] / 2) == Temp[0][0] / 2 and int(Temp[0][1] / 2) == Temp[0][1] / 2):
while True:
if Temp[1][0] % 2 == 0 and Temp[1][1] % 2 == 0 and Temp[0][0] % 2 == 0 and Temp[0][1] % 2 == 0:
Temp[0][0] //= 2
Temp[0][1] //= 2
Temp[1][0] //= 2
Temp[1][1] //= 2
else:
break
AminB.append(Temp[0][0] - Temp[1][0])
res = [Temp[0][0] + Temp[1][0], (Temp[0][1] * 2)]
while True:
if res[0] % 2 == 0 and res[1] % 2 == 0:
res[0] //= 2
res[1] //= 2
else:
break
X.append(res)
f.write('S = '+ str(S) + '\n')
if xQ == 'y':
f.write('x = ')
for i in X:
f.write(str(i[0]) + '/' + str(i[1]) + ', ')
f.write('\n')
f.write('A-B = ')
for i in AminB:
f.write(str(i) + ', ')
f.write('\n\n')
print('Complete!')
time.sleep(3)