Results 1 to 5 of 5
Thread: & Java
Hybrid View
-
13th January 2008 01:47 #1
& Java
,
:
a² + b² = c² .
a + b + c = 1000.
abc
, projecteuler.net .
, . 31875000
Code:public class Pythagoreantrapet { public static void main(String args[]) { double a=1; double b=1; double k; double kk; for(a=1;a<1000;a++){ for(b=1;b<1000;b++){ k=((a+b)+Math.pow((double)(a*a+b*b),(double)1/2)); kk=1000*(a+b)-a*b; if (kk==500000) { Out.println(k); Out.println(kk); } } } }}
-
13th January 2008 02:12 #2
, , , :
Code:>>> for a in range(1,1000): ... for b in range(a,1000): ... c = 1000 - (a + b) ... if (a*a + b*b) == c*c: ... print a, b, c, a*b*c ... 200 375 425 31875000
Internet - it doesn't make you stupid, it just makes your stupidity more accessible to others
-
13th January 2008 11:35 #3
int, .

A Pythagorean triplet is a set of three natural numbers, a<b<c, for which,
a² + b² = c²
For example, 3² + 4² = 9 + 16 = 25 = 5².
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
-
13th January 2008 12:57 #4
-
13th January 2008 14:13 #5




Reply With Quote

Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in