2
$\begingroup$

I am attempting to utilise the Condition function to replace all primes in the list by a 0.

Here are my codes:

Range[2000] /. x_ /; x \[Element] Prime -> 0

But it isn't performing as it should and I am unable to conceive an alternative syntax.

$\endgroup$

closed as off-topic by Szabolcs, gwr, b.gates.you.know.what, Simon Woods, J. M. will be back soon Mar 26 '17 at 14:35

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Szabolcs, gwr, b.gates.you.know.what, Simon Woods, J. M. will be back soon
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ Range[2000] /. x_ /; PrimeQ[x] -> 0 $\endgroup$ – andre314 Mar 26 '17 at 13:04
  • 1
    $\begingroup$ Range[2000] /. x_?PrimeQ :> 0also $\endgroup$ – ubpdqn Mar 26 '17 at 13:05
  • $\begingroup$ That should be Primes, not Prime. Prime is a function. Primes is a set. $\endgroup$ – Szabolcs Mar 26 '17 at 13:12
  • $\begingroup$ @Szabolcs Thank you for the heads up. $\endgroup$ – Physkid Mar 27 '17 at 9:51