# Defining variables [duplicate]

I want to define a variable for a set of computations to be a positive integer (or more generally, say I want to define it as integer or real, since Mathematica seems to take a variable as a complex one by definition). I am familiar with Fortran 95, where we define variables in the beginning to be integer or real, what is the corresponding set of command(s) in Mathematica for the same purpose. Thanks

## marked as duplicate by Szabolcs, MarcoB, garej, b3m2a1, m_goldbergJun 16 '17 at 0:46

• Outside of simply assigning a it a real or integer value? Not really. You can check the type using, e.g. Assert and MatchQ. I think you might be well served by reading a tutorial. It'll clear up your confusions and help you get started with the language. – b3m2a1 Jun 15 '17 at 3:55
• See the documentation for IntegerQ and Element for a partial answer to your question. – bbgodfrey Jun 15 '17 at 4:19
• Assuming that a is such an integer, positive variable, try to evaluate \$Assumptions[a > 0, a \[Element] Integer]; in the very first cell of your notebook. Mma will know this definition through the whole session. – Alexei Boulbitch Jun 15 '17 at 6:26