The }. and }: can be elided with a more amicable specification. (gppt U) -: }. }: dot&U^:flim^:a: mada 1 (gppt A) -: }. }: dot&A^:flim^:a: mada 1 (gppt D) -: }. }: dot&D^:flim^:a: mada 1
----- Original Message ----- From: Arie Groeneveld <[EMAIL PROTECTED]> Date: Saturday, July 14, 2007 9:48 Subject: [Jprogramming] Primitive Pythagorean Triples To: Programming forum <[email protected]> > > Here's my (primitive) work out in J > of generating primitive Pythagorean triples (ppt) based on > http://mathworld.wolfram.com/PythagoreanTriple.html > > Generator matrices > > U=: 1 2 2 , _2 _1 _2 ,: 2 2 3 > A=: 1 2 2 , 2 1 2 ,: 2 2 3 > D=: _1 _2 _2 , 2 1 2 ,: 2 2 3 > > Starting ppt > mada=: 3 4 5 > > Limiting expression for selecting primitives, > in this case only ppt's with hypotenuse < 100 > > flim =: 100 > {: > > dot =: +/ . * > > gppt =: 3 : 0 > M =. y > r =. ,: mada > ppt =. mada dot M > while. flim ppt do. > r=. r , ppt > ppt =. {: r dot M > end. > }. r > ) > > Array of ppts: > ppts=: mada, (gppt U) , (gppt D), (gppt A) > > > No doubt there's a more J-ish way in doing this, > especially for gppt ??!! > > greetings, ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
