# Re: Finding primes with q

**URL:** <https://forum.kx.com/t/re-finding-primes-with-q/12878>\
**Category:** Community Support\
**Tags:** blogs\
**Created:** [May 27, 2023, 10:03am UTC](https://forum.kx.com/t/re-finding-primes-with-q/12878 "2023-05-27T10:03:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajasekhark1](https://avatars.discourse-cdn.com/v4/letter/r/a6a055/32.png) [@rajasekhark1](https://forum.kx.com/u/rajasekhark1)\
**Post date:** [May 27, 2023, 10:03am UTC](https://forum.kx.com/t/re-finding-primes-with-q/12878/1 "2023-05-27T10:03:00Z")

</div>

Hi&nbsp;&nbsp;,

Thank you for great explanation that you provided to find prime numbers.

It seems there is a problem with functions you have created . It’s not giving correct prime numbers, I marked it in bold.

```
q)es[sieve1]10023 **4** 5711131719 **22** 23 **26** 29313437 **38** 4143 **46** 4753585961 **62** 6771737479 **82** 83 **86** 89 **94** 97  
q)es[sieve2;100]  
2 3 **4** 5 7 11 13 17 19 **22** 23 **26** 29 31 34 37 **38** 41 43 **46** 47 53 58 59 61 62 67 7..  

```

Just check with you, I was trying to run below function with **scan** instead of over because I want to verify mid results, however it is throwing type error.&nbsp;

```
es:{[s;N]{x,1+wherey}.({anyz#y}[;;floorsqrtN].)s **\** (2;0b,01bwhere1,N-2)}

```

&nbsp;Could you please revisit the solution you have provided.
