OFFSET
1,1
LINKS
Randall L Rathbun, Table of n, a(n) for n = 1..229
PROG
(C)
#include <stdio.h> /* printf() */ #include <math.h> /* sqrt() round() */
unsigned int is_triangle(int a, int b, int c) { double s, A, B; s = (a+b+c)/2.0; A = s*(s-a)*(s-b)*(s-c); B = floor(sqrt(A)+0.1); if ( B*B == A && A > 0.0 ) return 1; else return 0; }
int main() { int set; int a, b, c, p; for (p=1; p<15001; p++) { printf("%d ", p); set = 0; for (a=1; a<p; a++) { for (b=a; b<p; b++) { c = p-a-b; if (c >=b && c < a+b && b < a+c && a < b+c ) { if (is_triangle(a, b, c)) { set += 1; printf("[%d %d %d] ", a, b, c); } } } } printf(" "); printf("perimeter %d = %d ", p, set); } return 0; } /* Randall L Rathbun, Jan 26 2007 */
CROSSREFS
KEYWORD
nonn
AUTHOR
EXTENSIONS
More terms from Randall L Rathbun, Jan 26 2007
STATUS
approved