Avatar

Correct answer by
Community Advisor

IIRC this was the page I used as a reference, wikipedia has different algos:

View solution in original post