def main(): primes = GPE.sieve(int(10**3.5) + 1) for a in range(len(primes)): for b in range(a + 1, len(primes)): i = primes[a] j = primes[b] n = i * j ep = GPE.Euler_Phi(n, primes) if str(sorted(str(ep))) == str(sorted(str(n))): print(n, ep)
def main(): candidate = GPE.sieve(10**3) curbest = 0 curbestcand = (0, 0) for b in candidate: for a in range(-999, 1001, 2): if GPE.is_prime(a + b + 1): n = 0 while GPE.is_prime(n * n + n * a + b): n += 1 if n > curbest: curbest = n curbestcand = (a, b) print(curbestcand[0] * curbestcand[1])
def main(): f = open("102.txt", 'r') ans = 0 for line in f: cord = list(map(int, line.split(','))) a = GPE.Point(cord[0], cord[1]) b = GPE.Point(cord[2], cord[3]) c = GPE.Point(cord[4], cord[5]) S = GPE.triangle_area(a, b, c) s1 = GPE.triangle_area(a, b, GPE.Point(0, 0)) s2 = GPE.triangle_area(c, b, GPE.Point(0, 0)) s3 = GPE.triangle_area(a, c, GPE.Point(0, 0)) if S == s1 + s2 + s3: ans += 1 print(ans)
def main(): ub = 50000000 P = set() primes2 = GPE.sieve(int(pow(ub, 1 / 2)) + 1) primes3 = GPE.sieve(int(pow(ub, 1 / 3)) + 1) primes4 = GPE.sieve(int(pow(ub, 1 / 4)) + 1) c = 0 for (i, j, k) in itertools.product(primes2, primes3, primes4): c += 1 x = i**2 + j**3 + k**4 if x > ub: continue else: P.add(x) print(len(P))
def main(): count = 0 primes = GPE.sieve(10**6) for p in primes: u = len(str(p)) flag = True for i in range(u): if GPE.BinarySearch(int(rotation(i, p)), primes) > -1: flag = True else: flag = False break if flag: print(p) count += 1 print("answer is", count)
def main(): ans = 0 primes = GPE.sieve(10**8) for p in primes: if p==2 or p==3: continue ans += euler_381(p) print(ans)
def main(): ans = 0 abundants = [] for x in range(1, 28123): if sum(GPE.allDivisors(x)) > 2 * x: abundants.append(x) for cand in range(1, 28123): flag = 0 for check in abundants: if check > cand: break if GPE.BinarySearch(cand - check, abundants) != -1: flag = 1 break if flag == 0: ans += cand print(ans)
def main(): ans = 10**7 result = [False] * 1001 for i in range(1, 1000): x = i while True: x = GPE.sum_on_digit(x, sq) if x is 89: result[i] = False break if x is 1: result[i] = True break for i in range(1, 10**7 + 1): x = GPE.sum_on_digit(i, sq) if result[x]: ans -= 1 print(ans)
def main(): r = "7654321" for s in itertools.permutations(r): a = '' for x in s: a += (''.join(x)) a = int(a) if GPE.is_prime(a): print(a) return
def main(): plist = GPE.sieve(100000) twosq = [] for i in range(1, 300): twosq.append(i * i * 2) for task in range(3, 100000, 2): if GPE.BinarySearch(task, plist) == -1: flag = False for p in plist: if task - p <= 0: break if GPE.BinarySearch(task - p, twosq) >= 0: flag = True break if not flag: print(task) return else: continue
def main(): dp = [0]*1005 dp[0] = 1 primes = GPE.sieve(1000) for p in primes: for i in range(p, 1000): dp[i] += dp[i-p] for i in range(1,1000): if dp[i]>5000: print(f"ANSWER : {i}") break
def main(): genp = 0 tg = 8 prls = [] for i in range(1, 1000000): cand = [j for j in range(len(str(i)))] cd = GPE.powerset(cand) bst = 0 for st in cd: if len(st) > 0: cls = gen(i, st) ct = 0 for p in cls: if isprime(p): ct += 1 if ct == tg: print(cls[0]) return
def is_pentagonal(x): if GPE.BinarySearch(x, pentagonal_numbers) == -1: return False else: return True
def int_palindrome(n): return GPE.check_palindrome(str(n))
def isprime(x): return GPE.BinarySearch(x, pr) != -1
import time from lib import Gratus_PE_Util as GPE pr = GPE.sieve(1000000) vst = [False] * 1000000 def isprime(x): return GPE.BinarySearch(x, pr) != -1 def gen(x, checklist): ls = [[]] * 10 for i in range(10): ls[i] = list(str(x)) rls = [0] * 10 mk = False for i in range(10): for k in checklist: ls[i][k] = chr(ord('0') + i) if k == 0 and i == 0: mk = True rls[i] = int("".join(ls[i])) if mk: rls.remove(rls[0]) return rls def main(): genp = 0 tg = 8