def e343(n=2 * 10 ** 6): alist = [1 + k ** 3 for k in range(n + 1)] primes = primesd3(n + 2) print() for p in primes: for i in roots(p): for j in range(i, n + 1, p): while alist[j] > p and alist[j] % p == 0: alist[j] //= p return sum(alist) - n - 1
def e343(n = 2*10**6): alist = [1 + k**3 for k in range(n + 1)] primes = primesd3(n + 2) print() for p in primes: for i in roots(p): for j in range(i, n + 1, p): while alist[j] > p and alist[j] % p == 0: alist[j] //= p return sum(alist) - n - 1
def Euler_7(n = 10001): p = primesd3(10**6) print() return p[n-1] i =1 num = 0; while i<n: num +=1 if isprime(num): i +=1 return num
def Euler_7(n=10001): p = primesd3(10**6) print() return p[n - 1] i = 1 num = 0 while i < n: num += 1 if isprime(num): i += 1 return num
def e187(top = 10**8//2): print(time()-ti) #p = list(primesd2(top)) #print(len(p)) alist = primesd3(top) count = len(alist) print('start',time()-ti) b = True for i in range(1,len(alist)): tx = time()-ti m = tx//60 s = tx-(m*60) if i<10**5:print(i,'{}min {}sec'.format(m,s),end='\r') if i%10**5==0:print(i,'{}min {}sec'.format(m,s),end='\r') for j in range(i,len(alist)): if alist[i]*alist[j]>10**8:break count+=1 return count
def e187(top=10**8 // 2): print(time() - ti) #p = list(primesd2(top)) #print(len(p)) alist = primesd3(top) count = len(alist) print('start', time() - ti) b = True for i in range(1, len(alist)): tx = time() - ti m = tx // 60 s = tx - (m * 60) if i < 10**5: print(i, '{}min {}sec'.format(m, s), end='\r') if i % 10**5 == 0: print(i, '{}min {}sec'.format(m, s), end='\r') for j in range(i, len(alist)): if alist[i] * alist[j] > 10**8: break count += 1 return count
def e343_test(top=2*10**6): global primes primes = primesd3(top+1) print() vect = [i**3+1 for i in range(1,top+1)] result = 0 t = time() for i in range(len(vect)): if i%100==0:print(i) vect[i]=max(factors(vect[i])) vect[i]=phi(vect[i]) return sum(vect) for k in range(1,top+1): i = k**3+1 j = round(i**(1/3)) if j%100==0:print(j) global primes tmp = max(factors(i))#,primes)) result+=phi(tmp) return result
def e343_test(top=2 * 10 ** 6): global primes primes = primesd3(top + 1) print() vect = [i ** 3 + 1 for i in range(1, top + 1)] result = 0 t = time() for i in range(len(vect)): if i % 100 == 0: print(i) vect[i] = max(factors(vect[i])) vect[i] = phi(vect[i]) return sum(vect) for k in range(1, top + 1): i = k ** 3 + 1 j = round(i ** (1 / 3)) if j % 100 == 0: print(j) global primes tmp = max(factors(i)) # ,primes)) result += phi(tmp) return result
def Euler_10(top=2 * 10**6): return sum(maths.primesd3(top))
def Euler_10(top = 2*10**6): return sum(maths.primesd3(top))