JSFiddle - React, Tailwind, and code Playground

HTML

<body>
<div class="wrapper">
    <h1></h1>
    <form>
        <label for="num">Choose your number</label>
        <input type="text" value="" id="num"/>
        <input type="button" value="Submit" class="button"/>
        <p id="answer"></p>

    </form>
        
  <div id="myDiv"></div>
</div> 
</body>

CSS

.wrapper {
margin: 150px auto;
max-width: 800px;
text-align: center;
font-family: 'Oxygen', sans-serif;

}

form {
  padding: 4em 4em 2em;
  max-width: 400px;
  margin: 100px auto;
  border-radius: 10px;
}

label {
  display: block;
  font-size: 1.6em;
  margin: 0 0 .5em;
  color: #000;
}


input[type="text"],
input[type="button"] {
  display: block;
  background: #f5f5f5;
  border: 1px solid #848484;
  font-size: 1.8em;
  border-radius: 10px;
  margin: 30px auto;

}


table {
    margin: 0 auto;
    border: 5px solid black;
    border-radius: 10px;
    font-size: 24px;
    
}

JavaScript

$( ".button" ).click(function() {
var n = document.getElementById( "num" ).value; 
    var arr = [];
    for (i=0; i<n; i++)
    arr[i] = [];
    var sub = 1;
    var count = 1;
    i = 0;
    while (count <= n){   
    var loopcount = 1;
    while (loopcount <= n){
        arr[i].push(sub);
        sub += count;
        loopcount++;
    }
    count++;
    sub = count;
    i++;
    }
  
 
var $table = $( "<table></table>" );
var $newline = $( "<tr></tr>" );   
n = n - 1;
    for ( var i = 0; i < arr.length; i++ ){ 
    for ( var j = 0; j < arr.length; j++ ) {     
    var subarr = arr[i][j];
    var $cell = $( "<td></td>" );
    $cell.append( $( "<td></td>" ).html(subarr) );
    $table.append( $cell );
      //$table.append($newline); 
         if (j == n) {
            $table.append($newline);
        }
    }
     //$table.append($newline); 
}
//$("tr").eq(n).append($newline);
//$("table td:nth-child(n)").append($newline);   
$table.appendTo( document.body );

});