I entered

MinValue[{Prime[n], n>=1 && Element[n, Integers]}, n]

But I just got back what I entered. Why can mathematica not tell me the smallest prime is 2?


MinValue[{Prime[n], 1<=n<=10 && Element[n, Integers]}, n]

seems to be beyond it, which is bizarre since it only has to check 10 values.


1 Answer 1


Presumably the problem is that the derivative of Prime is undefined in Mathematica

D[Prime[n], n]

(*  Derivative[1][Prime][n]  *)

Use NMinValue

NMinValue[{Prime[n], 1 <= n}, n, Integers]

(*  2.  *)

NMinValue[{Prime[n], 1 <= n, Element[n, Integers]}, n]

(*  2.  *)

Round to taste.

  • $\begingroup$ Ah, thanks. I thought it had more methods than simply taking derivatives. $\endgroup$
    – user85798
    Dec 11, 2015 at 5:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.