34 lines
606 B
Python
34 lines
606 B
Python
def isprime(x):
|
|
if x <= 0:
|
|
return False
|
|
if x == 2:
|
|
return True
|
|
temp = 3
|
|
while temp <= int(x ** 0.5) + 1:
|
|
if x % temp == 0: return False
|
|
else: temp += 2
|
|
return True
|
|
|
|
|
|
delta = lambda x, y: 2 * x + y + 1
|
|
|
|
|
|
a = [0, 0, 0]
|
|
for j in xrange(1001):
|
|
if isprime(j):
|
|
for i in xrange(-1000, 1001):
|
|
n = 0
|
|
tmp = j
|
|
while 1:
|
|
tmp += delta(n, i)
|
|
if isprime(tmp):
|
|
#print j, '\t', i, '\t', tmp
|
|
n += 1
|
|
else:
|
|
break
|
|
if n > a[0]:
|
|
a[0] = n
|
|
a[1] = i
|
|
a[2] = j
|
|
print a[1] * a[2], '=', a[1], '*', a[2]
|