<!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> </head> <body> <script> var func = function(m, n){ var k = Math.ceil(m/n); var foo = ''; for (var i = 1; i<=k; i++) { for(var j = 1; j<=n;j++){ if (k*(j-1)+i<=m) foo += k*(j-1)+i+' '; } console.log(foo+"\r\n"); foo = ""; } }; func(13,3); </script> </body> </html>
console.table([[1,5,9],[2,6,10],[3,7,11],[4,8,12]]);