def main(): max = 0 product = 0 for a in range(-1000, 1001): for b in range(-1000, 1001): n = 0 maxCount = 0 while (lib.isPrime(n**2 + a * n + b)): n += 1 maxCount += 1 if maxCount > max: max = maxCount product = a * b return product
from lib import isPrime from math import sqrt n = 7 while True: n += 2 if isPrime(n): continue flag = False for i in range(2, n): if not isPrime(i): continue r = sqrt((n - i) / 2) if r == int(r): flag = True #print("%d = %d + 2x%d^2" % (n, i, int(r))) break if flag == False: print(n)
from lib import isPrime k = 4 n = 2 c = 0 while True: i = 2 s = set() m = n while i <= m: if isPrime(i): while m % i == 0: s.add(i) m = int(m/i) if len(s) > k: s = set() break i+=1 if len(s) == k: c += 1 else: c = 0 if c == k: print(n, len(s)) break n+=1
from lib import isPrime from itertools import permutations p = [] for n in range(1000, 10000): if isPrime(n): p.append(n) print("Start") for n in range(1000, 10000): if n % 1000 == 0: print(n) a = permutations(str(n)) r = set() for x in a: x = int(''.join(x)) if x in p: r.add(x) r = list(r) if len(r) < 3: continue r.sort() for i in range(0, len(r)): for j in range(i + 1, len(r)): for k in range(j + 1, len(r)): if r[i] + r[k] == 2 * r[j]: print(r[i], r[j], r[k])
from lib import isPrime p = [0, 0] d = 0 n = 1 c = 0 s = 1 t = 0 while True: if d == 0: p[0] += 1 n += 1 if abs(p[0]) == c: s += 1 if isPrime(n): t += 1 if abs(p[0]) > c: c += 1 d += 1 d %= 4 elif d == 1: p[1] += 1 n += 1 if abs(p[1]) == c: d += 1 d %= 4 s += 1 if isPrime(n): t += 1 elif d == 2: p[0] -= 1 n += 1 if abs(p[0]) == c:
from lib import isPrime k = 1000000 n = 1 r = [] while n <= k: n += 1 m = n if not isPrime(n): continue s = 0 a = 0 c = 0 d = 0 while s <= k: if isPrime(n): s += n c += 1 if s <= k and isPrime(s): d = c a = s n += 1 if [d, m, a] > r: r = [d, m, a] n = m print(r)
v = [] m = 0 digit = '0123456789' #for _ in range(1000): while True: s = str(n) char = list(set(s)) form = [] for x in char: form.append(s.replace(x, '*')) for f in form: if f in v: continue r = [] for d in digit: t = f.replace('*', d) if t[0] == '0': continue if isPrime(int(t)): r.append(int(t)) if len(r) > m: m = len(r) print(r) v.append(f) if n % 1000 == 0: print(n) n += 1 #[121313, 222323, 323333, 424343, 525353, 626363, 828383, 929393]