import utils from tqdm import tqdm N = utils.get_N() if utils.get_N() else int(1e6) n_range = range(1, N+1) primes = [i for i in tqdm(n_range) if utils.is_prime_faster(i)] def rotations(n): n = str(n) orig = n rots = [] while True: n = n[-1] + n[:-1] rots.append(n) if n == orig: break return [int(r) for r in rots] def is_cprime(rots): for num in rots: if num not in primes: return False return True c_primes = set() for n in tqdm(primes): if n in c_primes: continue
import sys import utils N = utils.get_N() if utils.get_N() else 1000 n_recursions = 2000 def limiter(new, *args): global counter counter += 1 ndigits = len(str(new)) if ndigits >= N: print(counter) return True return False for i in range(1, 10): sys.setrecursionlimit(n_recursions * i) counter = 3 try: utils.fibo(1, 2, limiter) sys.exit() except RecursionError: pass
import utils def digit_nth_power(digit, n): summ = sum([int(i)**n for i in str(digit)]) return summ == digit N = utils.get_N() if utils.get_N() else 5 digi = 10 digits = [] while len(str(digi)) < N + 2: if digit_nth_power(digi, N): print(digi) digits.append(digi) digi += 1 print(digits) print(sum(digits))
import utils N = utils.get_N() if utils.get_N() else 4 def is_cons_prms(i): for j in range(N): dprms = set(utils.get_prime_factors_faster(i + j)) if len(dprms) != N: return False return True i = 1 while True: print(i, end='\r') if is_cons_prms(i): print(i) break i += 1
import utils def get_cham_str(max_len): cham_str = "" i = 0 while len(cham_str) <= max_len: cham_str += str(i) i += 1 return cham_str N = utils.get_N() if utils.get_N() else 6 MAX = int(10**N) print(MAX) cham_str = get_cham_str(MAX) cons = 1 for i in range(1, N + 1): print(10**i, cham_str[10**i]) cons *= int(cham_str[10**i]) print(cons)
import sys import utils N = utils.get_N() if utils.get_N() else 2 my_range = list(range(N + 1)) counter = 0 last_perm = None def range_without_n(n, old_range): new_range = old_range.copy() new_range.remove(n) return new_range def permutate(objects, *args): global counter, last_perm if counter >= 1e6: # print(last_perm) sys.exit(last_perm) args = list(args) for n in objects: try: args.remove(n) except ValueError: pass if len(objects) > 1: for n in objects: