Exemplo n.º 1
0
        s += 1

        if s >= r:
            break

        a = r ** 2 - s ** 2
        b = 2 * r * s
        c = r ** 2 + s ** 2

        l = a + b + c

        if l > l_limit:
            break

        if (s % 2 == 0) ^ (r % 2 == 0) \
            and project_euler.gcd(s, r) == 1:

            # (r,s) produces primitive pythogorian right triangle
            print("r = {0}, s = {1}".format(r, s))

            d = 0
            while True:
                d += 1
                
                (a_s, b_s, c_s) = (a * d, b * d, c * d)
                l_s = a_s + b_s + c_s

                if l_s > l_limit:
                    break

                #print("({0}, {1}, {2}) L={3}".format(a_s, b_s, c_s, l_s ))
Exemplo n.º 2
0
import project_euler
import math

count = 0
for d in range(2, 12000 + 1):
    for n in range(max(1, math.floor(d / 3)), math.ceil(d / 2)):
        if n / d > 1/3 and n / d < 1/2:
            if project_euler.gcd(n, d) == 1:
                count += 1

    if d % 120 == 0:
        print('.', end="", flush=True)

print(count)