@Spirithaunter What is the point of stating that the location of a local declaration causes an issue in your own version of Maple without telling us what version it is?!
The code I posted can be adjusted easily to declare locals at the start of the procedures, if that was an issue for your version. That issue can be removed simply by changing the line,
to instead be,
since older versions (like, say, Maple 16) would reject the local declaration after the first statement terminator.
The code I posted already showed an alternate mechanism for a recursive call (procname).
There is no point in saying that you "corrected" my code without supplying what you did. How can I tell whether or not you made the same fundamental mistake as origianlly?! (You can use the green up-arrow in the Mapleprimes editor to upload and attach a worksheet. Please do so.)
I stand by my claim that your original code is confused by using the procedure's own name as an implicit local within itself as well as in a recursive call to itself.
I disagree that you should add explicit local declarations only when all else is finished and working properly. The code is already a heaving morass of print statements and obfuscated programming. Start (not finish) by correcting its structure and process.
Also, it's quite unclear how your code is supposed to work. It's entirely possible that there are other problems and coding mistakes remaining.