예제 #1
0
파일: e276.py 프로젝트: gtmanfred/Euler
def e276(top=10**7):
    count = 0
    for i in range(1, top):
        print(i)
        for j in range(1, top):
            if i + j > top: break
            for k in range(j - i + 1, j + i + 1):
                if i + j + k > top: break
                x = gcd(gcd(i, j), gcd(i, k))
                if x % 1 == 0: count += 1
    return count
예제 #2
0
파일: e276.py 프로젝트: gtmanfred/Euler
def e276(top = 10**7):
    count = 0
    for i in range(1,top):
        print(i)
        for j in range(1,top):
            if i+j>top:break
            for k in range(j-i+1,j+i+1):
                if i+j+k>top:break
                x = gcd(gcd(i,j),gcd(i,k))
                if x%1==0:count +=1
    return count
예제 #3
0
def e127(top):
    ret = 0
    l = 0
    for a, b in combo(range(1, top), 2):
        if not a & 1 and not b & 1: continue
        c = a + b
        if not a & 1 and not c & 1: continue
        if not c & 1 and not b & 1: continue
        if a != l:
            print(a, b, end='\r')
            l = a
        if a > b: continue
        if gcd(a, b) != 1 or gcd(b, c) != 1 or gcd(c, a) != 1:
            continue
        if rad(a, b, c) < c:
            ret += c
    print()
    return ret
예제 #4
0
파일: e127.py 프로젝트: gtmanfred/Euler
def e127(top):
    ret = 0
    l = 0
    for a,b in combo(range(1,top),2):
        if not a&1 and not b&1:continue
        c = a+b
        if not a&1 and not c&1:continue
        if not c&1 and not b&1:continue
        if a!=l:
            print(a,b,end='\r')
            l=a
        if a>b:continue
        if gcd(a,b)!=1 or gcd(b,c)!=1 or gcd(c,a)!=1:
            continue
        if rad(a,b,c)<c:
            ret+=c
    print()
    return ret
예제 #5
0
파일: e075.py 프로젝트: gtmanfred/Euler
def e75(top=1500000):
    count = 0
    alist = [0]*top
    tops = int(sqrt(top))
    for i in range(1,int(tops),2):
        for j in range(2,int(tops)-i,2):
            if i+j>top:break
            if gcd(i,j)==1:
                x = abs(j*j-i*i)
                y = 2*i*j
                z = j*j+i*i
                s = x+y+z
                for p in range(s,top,s):alist[p]+=1
    return alist.count(1)
    '''
예제 #6
0
파일: e075.py 프로젝트: gtmanfred/Euler
def e75(top=1500000):
    count = 0
    alist = [0] * top
    tops = int(sqrt(top))
    for i in range(1, int(tops), 2):
        for j in range(2, int(tops) - i, 2):
            if i + j > top: break
            if gcd(i, j) == 1:
                x = abs(j * j - i * i)
                y = 2 * i * j
                z = j * j + i * i
                s = x + y + z
                for p in range(s, top, s):
                    alist[p] += 1
    return alist.count(1)
    '''
예제 #7
0
def f(g, l, n):
    count = 0
    for combo in combos(range(1, l + 1), n):
        if g <= gcd(combo) and l >= lcm(combo):
            count += 1
    return count
예제 #8
0
파일: e350.py 프로젝트: gtmanfred/Euler
def f(g,l,n):
    count = 0
    for combo in combos(range(1,l+1),n):
        if g<=gcd(combo) and l>=lcm(combo):
            count +=1
    return count