Grindelvald,
<script>
function printNumbers(cNum, cols) {
var step = Math.ceil(cNum / cols);
for (var i = 0; i < step; i++) {
var str = i;
for (var k = 1; k < cols; k++) {
var n = i + step * k;
if (n < cNum) str += ' ' + n;
}
document.write(str + '<br>')
}
document.write('<br>')
}
printNumbers(12, 3);
printNumbers(13, 3);
printNumbers(15, 4);
</script>