sqrt under 1000

u.go
2015-04-14T09:53:33Z

gistfile1.js

| function isInt(n) {
| return n % 1 === 0;
| }
|
| var i, j;
| var count = 0;
|
| var uniq_d = {}
|
| for (i = 1000; i >= 3; i--) {
| uniq_d = {}
| for (j = i - 1; j >= i / 1.42; j--) {
| k = Math.sqrt(i * i - j * j);
| if (k != 0 && isInt(k)) {
| if (k in uniq_d) {
| continue;
| } else {
| console.log(i, j, k);
| count += 1;
| uniq_d[j] = true;
| uniq_d[k] = true;
| }
| }
|
|
| }
| }
|
| console.log(count);//881