Only get the data in the rows with prime numbers,

I have the following problem.

I have a DT, I want to only get the data in the rows with prime numbers, how can I iterate my DT to achieve this?

HI,

Hope the following sample helps you.

arrDr = dt.AsEnumerable.Where(Function(r) CInt(r(1))=2 OrElse  (CInt(r(1))>2 AndAlso Enumerable.Range(2,CInt(r(1))-2).All(Function(i) CInt(r(1)) mod i <>0))).ToArray

Sample20220330-2L.zip (3.1 KB)

Regards,

1 Like