Code Block
To create inline code, wrap the code with backticks ` .
To create a code block, place three backticks ```
above and below the code block.
def find_pythagorean_triples(max_num):
pythagorean_triples = []
for a in range(1, max_num + 1):
for b in range(a, max_num + 1): # Start from 'a' to avoid repetition
c = (a ** 2 + b ** 2) ** 0.5
if c.is_integer(): # Check if c is an integer
pythagorean_triples.append((a, b, int(c)))
return pythagorean_triples
# Set maximum value
max_value = 100
# Calculate and output Pythagorean triples
triples = find_pythagorean_triples(max_value)
print("Pythagorean triples up to", max_value, ":")
for triple in triples:
print(triple)
PREVIEW