# Author : Steven Miller # Course Number : 22C:016 SCA # Student ID : 4784653 import math # Enter the cutoff M M = int(raw_input("Enter a positive integer for M: ")) count = 0 # Number of quadruples found a = 1 # Loop through values of a from 1 to M-1 while (a <= M) : asquared = a * a b = a # Loop through the values of y from x+1 to M while (b <= M) : bsquared = b * b c = b while (c <= M) : csquared = c * c abc_squared = asquared + bsquared + csquared # Compute the nearest integer to square root of dsquared d = int(math.sqrt(abc_squared)) # Found a pythagorean quadruple if abcsquared = d*d if d * d == abc_squared : count = count + 1 print a, b, c, d c = c + 1 b = b + 1 a = a + 1 print "The number of quadruples found is", count