var num = 5;
var m, n;
for (m = num; m >= 0; m--) {
    for (n = 1; n <= m; n++) document.write("" + n + " ");
    document.write("<br/>");
}
for (m = 1; m <= num; m++) {
    for (n = 1; n <= m; n++) document.write("" + n + " ");
    document.write("<br/>");
}
