"Algorithm 288, Solution of linear Diophantine systems" - читать интересную книгу автора (Blankinship.)