Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def factiorials(max_n):
- f = [0]
- x = 1
- for i in range(1, max_n+1):
- x *= i
- f.append(x)
- return f
- def isPrime(j, f):
- return (f[j-1]+1)%j == 0
- def solution(n):
- max_int= int((n+5)*(5000/2465)+475)
- facts = factiorials(max_int)
- id_str = ''.join([str(x) for x in range(2, max_int+1) if isPrime(x, facts)])
- return id_str[n:n+5]
- from time import perf_counter
- start = perf_counter()
- for i in range(10000):
- s = perf_counter()
- print(i, solution(i), f"completed in: {perf_counter()-s}s")
- print(f"elapsed {perf_counter()-start}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement