Anonymous ID: aeeab0 Jan. 26, 2018, 9:28 p.m. No.3404   🗄️.is 🔗kun   >>3405 >>3406

>>3402

def getGCD(A, B):

if B == 0:

return A

else:

return getGCD(B, A % B)

 

def factor(number):

C = number

D = int(math.sqrt(C))#can be any number s.t. d^2 < C

E = C - D*D

 

newX = E%2

if(newX == 1):

dShift = 6

else:

dShift = 4

newD = int((newX*(newX+2)+E)//2)

newA = newD - newX

GCD = 1

dCand = newD - D

while(GCD == 1):

newX += 2

newD += dShift

dCand += dShift

dShift += 4

newA = newD - newX

GCD = getGCD(dCand, newA)

 

print(D-newX, GCD)

#return GCD

#newA = D - newX

#If we switch up the D value, one of these might be negative but it will still be a factor

return newA

 

This is all the Python code. I switched up the loop to make it fewer calculations but there may be a better way.

 

>>3403

Yes