<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Спойлеры</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<link rel="stylesheet" href="test.css">
</head>
<body>
<script>
var func = function(m, n){
var k = Math.floor(m/n);
var foo = '';
for (var i = 1; i<=k; i++) {
for(var j = 1; j<=n;j++){
foo += k*(j-1)+i+' ';
}
console.log(foo+"\r\n");
foo = "";
}
};
func(12,3);
</script>
</body>
</html>