import math
def gcd(x, y):
if x > y:
t = x
x = y
y = t
if x == 0:
return y
return gcd(x, y % x)
def check(x, y, z, r):
return (z <= r) and gcd(x, y) == 1 and gcd(x, z) == 1 and gcd(y, z) == 1
a, b = map(int, input().split())
for i in range(a, b):
for j in range(i, b):
if check(i, j, math.sqrt(i * i + j * j), b):
print(str(i) + " " + str(j) + " " + str(int(math.sqrt(i * i + j * j))))
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
import math
def gcd(x, y):
if x > y:
t = x
x = y
y = t
if x == 0:
return y
return gcd(x, y % x)
def check(x, y, z, r):
return (z <= r) and gcd(x, y) == 1 and gcd(x, z) == 1 and gcd(y, z) == 1
a, b = map(int, input().split())
for i in range(a, b):
for j in range(i, b):
if check(i, j, math.sqrt(i * i + j * j), b):
print(str(i) + " " + str(j) + " " + str(int(math.sqrt(i * i + j * j))))