GCD
by evgkch
HTML
<canvas id='canvas'></canvas>
JavaScript
const canvas = document.getElementById('canvas');
const size = 10000;
const s = 1000;
const step = size / s;
canvas.width = size
canvas.height = size
const ctx = canvas.getContext('2d');
function gcd(a, b) {
return b ? gcd(b, b % a) : a;
}
ctx.globalAlpha = 0.1
ctx.beginPath();
for (let x = 0; x < s; x++) {
for (let y = 0; y < s; y++) {
const a = gcd(x, y);
const b = x * y / a;
ctx.moveTo(x * step, y * step);
ctx.lineTo(b * step, a * step);
}
}
ctx.stroke()
ctx.closePath();