Search code examples
wolfram-mathematica

How to find the smallest positive integer value of n when n is described as an interval, in Mathematica


So, my calculation gives me the following output:

n \[Element] Integers &&(n<0 || n>=2)

How do I parse\compute this in a way that yields me (in this case) 2, which I then can use in further calculations?


Solution

  • You want the smallest so use Minimize with constraints on the solution.

    Minimize[{n,n \[Element] Integers &&(n<0 || n>=2) && n>0},n]
    

    which instantly returns

    {2,{n->2}}