In General, patenting is not prohibited, if I understand correctly, GK-4. But, allowed to be patented just like any engineering models. That is, the algorithm simply does not fall in the category of things that can be patented. And rightly so. Because, after six months, someone else will guess this algorithm, and it is impossible for him to deny doing it.
If You need the recognition of authorship — just publish. Plagiarism (or in ignorance of the related works) then you can always foe to catch, citing the relevant article.