Oh, yes! That sure was too obvious and too easy for me too see Image may be NSFW.
Clik here to view.
In the attached sheet I nevertheless had to resort to my alternative approach as I don't use the precalculated triples.
Image may be NSFW.
Clik here to view.
The routines are written so that the argument is either a scalar (highes prime number involved) or, as in Liu's routine, a vector of primes.
So if you want to collect all routines in one programm as in the original sheet, you would calculate the prime list only once.