def calc(): mydiv = Divisors(100000000) searching = True number = 3 t = 2 while searching: t += 1 number += t factors = mydiv.prime_factors(number) num_of_fac = 1 for ele in factors: num_of_fac *= ele[1] + 1 if num_of_fac > 500: searching = False return number
def calc(n): ammic = [] mydiv = Divisors(n) for i in range(2, n): j = sum_divis(i, mydiv) if sum_divis(j, mydiv) == i and i != j: ammic.append(i) result = 0 for ele in ammic: if ele < n: result += ele return result
from eulerlib import Divisors from math import gcd divi = Divisors() n = 1 r = 0 for i in range(1, n): for j in range(i + 1, n + 1): r += gcd(i, j) print(r) k = 1 p = 7 r = 0 for l in range(k + 1): for d in range(l + 1): r += (p**d) * divi.phi(p**(l - d)) print(r)
from eulerlib import Divisors from math import gcd N = 1000001 divobj = Divisors(N) def funcion(n): global d divis = divobj.divisors(n) r = 0 # print("divis {}".format(divis)) for d in divis[:]: r += d * divobj.phi(n // d) # print("d {} phi {} es {}".format(d,n//d,divobj.phi(n//d))) return int(r) for i in range(1, N + 1): # print("f[{}]={} phi {}".format(i,funcion(i),int(divobj.phi(i)))) print("f[{}]={}".format(i, funcion(i)))
# -*- coding: utf-8 -*- """ Created on Sun Oct 20 12:24:06 2019 @author: infoplus """ MAXNUM = 28123 from eulerlib import Divisors mydiv = Divisors(MAXNUM+1) #def is_abundant(i): # return i < sum(mydiv.divisors(i)[:-1]) def divisorsum(n): return sum(i+int(n/i) for i in range(1,int(n**0.5)+1)) def is_abundant(i): return i < (divisorsum(i)-i) numbers = [i for i in range(MAXNUM+1)] abundants = [i for i in numbers[1:] if is_abundant(i)] for i in range(MAXNUM+1): for j in range(i+1): tmp = abundants[i]+abundants[j] if tmp<=MAXNUM: numbers[tmp]=0 print(sum(numbers))
#!/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 from eulerlib import Divisors from functools import reduce import sys d = Divisors(1E5) for line in sys.stdin: if line: n = int(line) phi = int(d.phi(n)) # print("n {} phi {}".format(n,phi)) print(phi >> 1)
import sys sys.path.append( "c:\\users\\conrad pearson\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages" ) #eulerlib is useful for finding divisors #but too slow on this scale from eulerlib import Divisors #this sets max value of which divisors can be found div = Divisors(100000000) #initialize our triangle number and other useful variables triangle = 0 max_div = 0 i = 0 #iterate and find next triangle number until condition is met while max_div < 500: i += 1 triangle += i max_div = len(div.divisors(triangle)) print(triangle) #expected value: 76576500
from eulerlib import Divisors from functools import reduce d=Divisors() #print(d.phi(123)) n=10 i=1 r=0 for i in range(1,n+1): phi=d.phi(i) ci=n//i print("i {} ci {} phi {}".format(i,ci,phi)) r+=phi*(ci*(ci-1))//2 print(r) n=200000 i=1 r=0 while(i<=n): la=n//(n//i) ci=n//i print("i {} ci {} la {} rang {}".format(i,ci,la,list(range(i,la+1)))) suma_phi=reduce(lambda x,y:x+d.phi(y),range(i,la+1),0) print("phis {} {}".format(list(range(i,la+1)), list(map(d.phi,range(i,la+1))))) print("sum phi {}".format(suma_phi)) r+=((ci*(ci-1))//2)*suma_phi i=la+1 print(r)