I am close to clean up the C translated code from Rosetta code and will post it tomorrow. Just need to fix the example, basically Pascalify it, but the core function is ready and did not take too much time, as I expected.
BTW the UCSD version from 41 years ago showed up in Google....
For good measure, though.
I used the ucsd version for teaching purposes, but did not write it.
I wrote a TurboPascal version
A good reader would have understood that.