login
Perimeters of integer triangles, sorted by perimeter, sides lexicographically ordered.
19

%I #20 Jul 09 2017 16:15:14

%S 3,5,6,7,7,8,9,9,9,10,10,11,11,11,11,12,12,12,13,13,13,13,13,14,14,14,

%T 14,15,15,15,15,15,15,15,16,16,16,16,16,17,17,17,17,17,17,17,17,18,18,

%U 18,18,18,18,18,19,19,19,19,19,19,19,19,19

%N Perimeters of integer triangles, sorted by perimeter, sides lexicographically ordered.

%C A005044(p) is the number of all integer triangles having perimeter p.

%H R. Zumkeller, <a href="/A070080/a070080.txt">Integer-sided triangles</a>

%F a(n) = A070080(n) + A070081(n) + A070082(n).

%t maxPer = 19; maxSide = Floor[(maxPer-1)/2]; order[{a_, b_, c_}] := (a+b+c)*maxPer^3 + a*maxPer^2 + b*maxPer + c; triangles = Reap[Do[If[ a+b+c <= maxPer && c-b < a < c+b && b-a < c < b+a && c-a < b < c+a, Sow[{a, b, c}]], {a, 1, maxSide}, {b, a, maxSide}, {c, b, maxSide}]][[2, 1]]; Total /@ Sort[triangles, order[#1] < order[#2] &] (* _Jean-François Alcover_, Jun 12 2012 *)

%t maxPer = m = 22; sides[per_] := Select[Reverse /@ IntegerPartitions[per, {3}, Range[Ceiling[per/2]]], #[[1]] < per/2 && #[[2]] < per/2 && #[[3]] < per/2&]; triangles = DeleteCases[Table[ sides[per], {per, 3, m}], {}] // Flatten[#, 1]& // SortBy[Total[#] m^3 + #[[1]] m^2 + #[[2]] m + #[[1]]&]; Total /@ triangles (* _Jean-François Alcover_, Jul 09 2017 *)

%K nonn

%O 1,1

%A _Reinhard Zumkeller_, May 05 2002