index.html
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<title>Cantor pairing function</title>
<style>
td { min-width: 2em; text-align: right; }
</style>
</head>
<body>
<p>Mapping tuples (n, m) to the integers, see <a href="//en.wikipedia.org/wiki/Cantor_pairing_function#Cantor_pairing_function">Cantor pairing function</a>.
<table id="cantor"></table>
<script>
function f(x, y) {
return ((x + y) * (x + y + 1)) / 2 + y;
}
for (var y = 0; y < 100; y++) {
var line = ['<tr>'];
for (var x = 0; x < 30; x++) {
line.push("<td>" + f(y, x) + "</td>");
}
line.push("</tr>")
$("#cantor").append(line.join(''));
}
</script>
</body>
</html>