Re: Re: Finding the Number of Pythagorean Triples below a bound
- To: mathgroup at smc.vnet.net
- Subject: [mg68428] Re: [mg68409] Re: Finding the Number of Pythagorean Triples below a bound
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Sat, 5 Aug 2006 03:46:05 -0400 (EDT)
- References: <eaeqa3$53v$1@smc.vnet.net><eakfgm$rl6$1@smc.vnet.net> <200608020923.FAA28520@smc.vnet.net> <79C36C70-E091-4A82-8EC5-0EDC743D081D@mimuw.edu.pl> <easiva$fp3$1@smc.vnet.net> <200608040759.DAA01035@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 4 Aug 2006, at 09:59, titus_piezas at yahoo.com wrote: > Hello Andrzej, > > The code I used was this: > > c1=Sqrt[N[a^2+b^2-k]]; > > countTriples[m_]:=Block[{a,b,i=0},For[a=1,a<(10^m/Sqrt[2]),a++, > For[b=a,b<10^m,b++,If[c1==Round[c1]&&c1<10^m,i++]]];i] > > though m=3 takes about 50 sec (in an old comp) while m=4 will > prolly be > > around 5000 sec (83 mins). > > > -Titus > This is very odd indeed. For example, I get: c1=Sqrt[N[a^2+b^2-k]]; countTriples[m_]:=Block[{a,b,i=0},For[a=1,a<(10^m/Sqrt[2]),a++, For[b=a,b<10^m,b++,If[c1==Round[c1]&&c1<10^m,i++]]];i] In[6]:= k=3; countTriples[2] Invalid comparison with 0. I attempted. 13 The correct answer is: f[10^2,-3] 28 Similarly for other values. Your code usually doesn't work on my machine and when it does it produces wrong answers. Andrzej Kozlowski
- References:
- Re: Finding the Number of Pythagorean Triples below a bound
- From: titus_piezas@yahoo.com
- Re: Finding the Number of Pythagorean Triples below a bound
- From: titus_piezas@yahoo.com
- Re: Finding the Number of Pythagorean Triples below a bound