Ejemplo n.º 1
0
def p_1(n):
	a = 2
	root = int(math.sqrt(n))

	for i in xrange(1, 50):
		a = pow(a, i)%n
		f = ex4.mdc(a - 1, n)

		if f > 1:
			return (f, n/f)
Ejemplo n.º 2
0
def dixon(n):
	base = [-1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
	l1 = []
	l2 = []

	for i in range(500, n):
		for j in base:
			if i*i % n == j*j % n:
				l1.append([i,j])

	for i in l1:
		factor = ex4.mdc(i[0] - i[1], n)
		if factor != 1:
			return (factor, int(n/factor))