Update all new Tasks

This commit is contained in:
Ingy döt Net 2015-02-20 09:02:09 -05:00
parent 00a190b0a6
commit 91df62d461
5697 changed files with 93386 additions and 804 deletions

View file

@ -0,0 +1,50 @@
window.onload = function(){
var list = [];
var j = 0;
for(var c = 1; c <= 200; c++)
for(var b = 1; b <= c; b++)
for(var a = 1; a <= b; a++)
if(gcd(gcd(a, b), c) == 1 && isHeron(heronArea(a, b, c)))
list[j++] = new Array(a, b, c, a + b + c, heronArea(a, b, c));
sort(list);
document.write("<h2>Primitive Heronian triangles with sides up to 200: " + list.length + "</h2><h3>First ten when ordered by increasing area, then perimeter:</h3><table><tr><th>Sides</th><th>Perimeter</th><th>Area</th><tr>");
for(var i = 0; i < 10; i++)
document.write("<tr><td>" + list[i][0] + " x " + list[i][1] + " x " + list[i][2] + "</td><td>" + list[i][3] + "</td><td>" + list[i][4] + "</td></tr>");
document.write("</table><h3>Area = 210</h3><table><tr><th>Sides</th><th>Perimeter</th><th>Area</th><tr>");
for(var i = 0; i < list.length; i++)
if(list[i][4] == 210)
document.write("<tr><td>" + list[i][0] + " x " + list[i][1] + " x " + list[i][2] + "</td><td>" + list[i][3] + "</td><td>" + list[i][4] + "</td></tr>");
function heronArea(a, b, c){
var s = (a + b + c)/ 2;
return Math.sqrt(s *(s -a)*(s - b)*(s - c));
}
function isHeron(h){
return h % 1 == 0 && h > 0;
}
function gcd(a, b){
var leftover = 1, dividend = a > b ? a : b, divisor = a > b ? b : a;
while(leftover != 0){
leftover = dividend % divisor;
if(leftover > 0){
dividend = divisor;
divisor = leftover;
}
}
return divisor;
}
function sort(list){
var swapped = true;
var temp = [];
while(swapped){
swapped = false;
for(var i = 1; i < list.length; i++){
if(list[i][4] < list[i - 1][4] || list[i][4] == list[i - 1][4] && list[i][3] < list[i - 1][3]){
temp = list[i];
list[i] = list[i - 1];
list[i - 1] = temp;
swapped = true;
}
}
}
}
}

View file

@ -0,0 +1,23 @@
Primitive Heronian triangles with sides up to 200: 517
First ten when ordered by increasing area, then perimeter:
Sides Perimeter Area
3 x 4 x 5 12 6
5 x 5 x 6 16 12
5 x 5 x 8 18 12
4 x 13 x 15 32 24
5 x 12 x 13 30 30
9 x 10 x 17 36 36
3 x 25 x 26 54 36
7 x 15 x 20 42 42
10 x 13 x 13 36 60
8 x 15 x 17 40 60
Area = 210
Sides Perimeter Area
17 x 25 x 28 70 210
20 x 21 x 29 70 210
12 x 35 x 37 84 210
17 x 28 x 39 84 210
7 x 65 x 68 140 210
3 x 148 x 149 300 210