PCPOTATO
Navigation

Home
About
Contact
Resume

Projects

None yet

Categories

General
Interesting
Programming

Archives

August 2008
July 2008
June 2008
May 2008
April 2008
Project Euler #9 July 14th, 2008

Finding the only Pythagorean triplet, {a, b, c}, for which a + b + c = 1000.

1
2
3
4
5
6
7
for i in range(1000):
    for j in range(1000):
        for k in range(1000):
	    if ((i + j + k == 1000) and (i*i + j*j == k*k)
 and (i < j) and (i < k) and (j < k)):
	        print i, j, k, i * j * k
		break
Leave a Reply

You must be logged in to post a comment.

Domains


Links


Presence


Meta

Log in