Question: This program is a basic attempt at finding a pair of twin primes each, before and after a given numerical value on the whole number line.The code looks good but is not giving any output and neither is it terminating post a run.I would like to know what is wrong with it.Thanks! 

```
public class twin {

    public boolean prime(int num) { // function to check for a prime number

        if (num % 2 == 1 && (num % 3 == 2 || num % 3 == 1)) {
            return true;

        } else
            return false;

    }

    public static void main(String args[]) { // main
        int inp_num = 7; // given number too check for twin primes before or
                            // after it
        twin ob = new twin();
        int arr[] = new int[5];
        for (int x = inp_num; x > 0; x--) { // checking limit [o,inpnum)
            boolean b = ob.prime(x);
            if (b = true) {
                if (ob.prime(x - 2) == true) {
                    arr[0] = x;
                    arr[1] = x - 2;
                }

            }

        }
        for (int x = inp_num; x >= inp_num; x++) { // checking limit
                                                    // [inpnum,infinity]
            boolean b = ob.prime(x);
            if (b = true) {

                if (ob.prime(x + 2) == true) {
                    arr[2] = x;
                    arr[3] = x + 2;
                }

            }

        }
        for (int i = 0; i < 4; i++) {
            System.out.println(arr[i] + "\t");

        }
    }
}

```

Answer: 
You can use multiplyMatrices() function from: <http://tech.pro/tutorial/1527/matrix-multiplication-in-functional-javascript> it works like charm. Example (You can print a matrix with style in Chrome and Firefox console with console.table() ):

```js
function multiplyMatrices(m1, m2) {
    var result = [];
    for (var i = 0; i < m1.length; i++) {
        result[i] = [];
        for (var j = 0; j < m2[0].length; j++) {
            var sum = 0;
            for (var k = 0; k < m1[0].length; k++) {
                sum += m1[i][k] * m2[k][j];
            }
            result[i][j] = sum;
        }
    }
    return result;
}

var m1 = [[1,2],[3,4]]
var m2 = [[5,6],[7,8]]

var mResult = multiplyMatrices(m1, m2)

/*In Google Chrome and Firefox you can do:*/

console.table(mResult) /* it shows the matrix in a table */
```

![Result matrix in console.table()](https://i.stack.imgur.com/y27ch.png)
You can *now* achieve this using TensorFlow.js:

```html
<!DOCTYPE html>
<html>
  <head>
    <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@3.0.0/dist/tf.min.js"></script>
    <script>
      const matrix_1 = tf.tensor([[1,2],[3,4]]);
      const matrix_2 = tf.tensor([[5,6],[7,8]]);

      const matrix_result = tf.matMul(matrix_1, matrix_2);
      matrix_result.print()
    </script>
  </head>
  <body>
    <h1>Check the console log!</h1>
  </body>
</html>

```