extended euclidean algorithm | ScratchStats