12-31-2022, 02:07 AM
Barely remember that MOD operator thread that went a ridiculous number of posts, and something about it. This is something I have used many times programming in BASIC and in Lua. Where [n] is the dividend and when the answer requires [1,n] and not [0,n-1].
Code: (Select All)
FUNCTION modslide~&& (divi AS _UNSIGNED _INTEGER64, dsor AS _UNSIGNED _INTEGER64)
'the following line should be to report an error in calculation:
IF dsor = 0 THEN modslide = 0 : EXIT FUNCTION
modslide = ((divi - 1) MOD dsor) + 1
END FUNCTION