diff options
author | Puneeth Chaganti | 2010-01-12 19:03:34 +0530 |
---|---|---|
committer | Puneeth Chaganti | 2010-01-12 19:03:34 +0530 |
commit | e7c314cb1d20800f929951eeac75e046528a36c8 (patch) | |
tree | 1aa4fed41387bb6e82a0cd5662eb5ad2891a6e7d /day1/exercise/pytriads.py | |
parent | ff739ac283432d46ae2c3b527d1999cd24029b86 (diff) | |
download | workshops-e7c314cb1d20800f929951eeac75e046528a36c8.tar.gz workshops-e7c314cb1d20800f929951eeac75e046528a36c8.tar.bz2 workshops-e7c314cb1d20800f929951eeac75e046528a36c8.zip |
Changes made during REC Chennai workshop.
Diffstat (limited to 'day1/exercise/pytriads.py')
-rw-r--r-- | day1/exercise/pytriads.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/day1/exercise/pytriads.py b/day1/exercise/pytriads.py index 4c47313..bea543d 100644 --- a/day1/exercise/pytriads.py +++ b/day1/exercise/pytriads.py @@ -10,12 +10,8 @@ def gcd(a, b): else: return gcd(b, a%b) -a = 3 -while a < 100: - b = a + 1 - while b < 100: - is_ps, c = is_perfect_square((a * a) + (b * b)) - if is_ps and gcd(a, b) == 1: - print a, b, c - b += 1 - a += 1 +for a in range(3, 501): + for b in range( a+1, 501, 2): + if gcd( a, b ) == 1: + is_ps, c = is_perfect_square((a * a) + (b * b)) + if is_ps: print a, b, c |