Need a practical solution for creating pattern database(5-5-5) for 15-Puzzle

For static pattern database(5-5-5), see this(page 290 and 283) OR there is an explanation below. For What is 15-puzzle?
I am creating a static patter database(5-5-5). This code to to fill entries into the first table. I am doing it via the recursive function insertInDB(). The first input to the recursive function is this (actually the input puzzle contains it in 1-D array. For better understanding I have represented it as 2-D below)

Two recursive functions and stackoverflow errors in javascript/nodeJs. Understanding the differences

Looking into the SICP book and JS functional programming I created two recursive functions. My expectation was that both of them raised a stack overflow error.
But it is only the sumAll() function that raised the error. See below the code for both functions sumAll() and factorial():

Node.js – Maximum call stack size exceeded

When I run my code, Node.js throws a "RangeError: Maximum call stack size exceeded" exception caused by too many recursive calls. I tried to increase Node.js stack size by sudo node --stack-size=16000 app, but Node.js crashes without any error message. When I run this again without sudo, then Node.js prints 'Segmentation fault: 11'. Is there a possibility to solve this without removing my recursive calls?

Exception of type ‘System.StackOverflowException’ was thrown OnModelCreating in ASP.NET MVC

I have received StackOverflowException as when I want to run my project. I got this error several times but after a while it’s gone and I didn’t received it until now that I can’t run my project at all. I don’t know exactly why Visual studio 2019 can’t run my project and build my context. For notice, I have a large database which I create my code first context by “CodeFirst From Database” operation.