Series from For loop (is there a repository for Integer Sequences?)

Both outputs match mine! Only diff. is due to use of str(), mine is 1 line of values for the whole array w/o indices; while yours display each array’s [index] value pair at its own line.
But the actual array’s contents are the same for both versions!

Why are you declaring global variables lo & dir instead of inside the functions that exclusively depend on them?
Besides decreasing performance, it also makes those functions thread-unsafe!

if you’d add back keyword static, your function will refuse to compile w/ message:
“Cannot make a static reference to the non-static field lo/dir”

It’d reveal that your version of those functions now depend on the state of the rest of the PApplet sketch.

But a high quality & robust function should be isolated and completely independent from the rest of the code.

It doesn’t make sense for the same functionality to have different function names.

For example, does it make sense to you for Processing function random() w/ overloaded version w/ 1 parameter high & the version w/ 2 parameters low & high to have different names?

Should random(50) & random(0, 50) be renamed to something like:
randomWith1Param(50) & randomWith2Params(0, 50)?

Also notice that first_function(4, 20) is equivalent to second_function(4, 1, 20).
And first_function(4, -20) is equivalent to second_function(4, -1, -20).

And in the second_function(-1, 10, -10), the -1 is an illegal argument. It should be 1 instead!

The reason I was passing -1 was to test if my function would sanitize it to a positive value using abs(n)!