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: 
I know it's an old question but I **recommend** to switch to my answer.

> 
> My solution's got good performance because it uses `Map` `Reduce`
>  functions
> 
> 
> 

```js
//The chosen one
function matrixDot (A, B) {
    var result = new Array(A.length).fill(0).map(row => new Array(B[0].length).fill(0));

    return result.map((row, i) => {
        return row.map((val, j) => {
            return A[i].reduce((sum, elm, k) => sum + (elm*B[k][j]) ,0)
        })
    })
}

var print = m => m.forEach(r => document.write(`&nbsp;&nbsp;${r.join(' ')}<br/>`)) 

var a = [[8, 3], [2, 4], [3, 6]]
var b = [[1, 2, 3], [4, 6, 8]]

document.write('matrix a:<br />');
print(a);
document.write('matrix b:<br />');
print(b);
document.write('a * b =<br />');
print(matrixDot(a,b));
```
```js
const getDot = (arrA, arrB, row, col) => {
    return arrA[row].map((val, i) => (val * arrB[i][col]))
  .reduce((valA, valB) => valA + valB);
}

const multiplyMatricies = (a, b) => {
    let matrixShape = new Array(a.length).fill(0)
      .map(() => new Array(b[0].length).fill(0));
        return matrixShape.map((row, i) =>
          row.map((val, j) => getDot(a, b, i, j)));
      }

    const arrA = [
      [1, 3, 0],
      [2, 1, 1]
    ];
    const arrB = [
      [1, 2, 0, 1],
      [2, 3, 1, 2],
      [1, 2, 1, 1]
    ];

    let product = multiplyMatricies(arrA, arrB);
    console.log("product:", product);
```