A006339

Emeric Deutsch deutsch at duke.poly.edu
Tue Jan 17 19:39:33 CET 2006


On Mon, 16 Jan 2006, David Wilson wrote:

> Someone has asked me how to compute A006339(n), and I've forgotten how.
>
> --------------------------------
> - David Wilson


Here is an elementary (and, therefore, not necessarily the simplest)
Maple program:

A006339:=proc(n) local ct,x,y: ct:=0: for x from 1 to n-1 do for y from 1 
to x do if x^2+y^2=n^2 then ct:=ct+1 else ct:=ct: fi: od: od: ct; end;

The next one will give the legs of the triangles.

b:=proc(n) local P,x,y: P:={}: for x from 1 to n-1 do for y from 1 to x do 
if x^2+y^2=n^2 then P:=P union {[x,y]} else P:=P: fi: od: od: P; end;

For example, A006339(1105)=13 and
b(1105)={[884, 663], [817, 744], [1020, 425], [975, 520], [952, 561], 
[1092, 169], [1071, 272], [1001, 468], [943, 576], [855, 700], [1100, 
105], [1104, 47], [1073, 264]}

Of course, the two programs can be combined into one:

a:=proc(n) local P,x,y: P:={}: for x from 1 to n-1 do for y from 1 to x do 
if x^2+y^2=n^2 then P:=P union {[x,y]} else P:=P: fi: od: od: print(P); 
nops(P): end;

which gives, for example,
a(25);
 		{[20,15],[24,7]}
 			2

Emeric







More information about the SeqFan mailing list