math: fix small memory leak in prime numbers