Prime numbers constraint

class prime_numbers;
  rand int unsigned prime[];
  constraint const_prime {prime.size inside{1000}; 

                          foreach(prime[i])
                            if (i>1 && (!((i%2==0 && i!=2) || (i%3==0 && i!=3)  ||  (i%5==0 && i!=5) ||  (i%7==0 && i!=7) || (i%11==0 && i!=11))))
                              prime[i]==i;
                          else
                            prime[i]==2;
                         }

  function void post_randomize;
    prime = prime.unique();
  endfunction

endclass

module tb();
  prime_numbers pm;

  initial
    begin
      pm=new();
      assert(pm.randomize());
      $display("the prime: %p",pm.prime);
    end
endmodule

Could some one help me with the prime numbers code that i got 989 non prime number in the range {0:1000}?

Another popular question:

https://verificationacademy.com/forums/search?q=prime%20number%20constraint