WolframLang: Arithmetic Basics

By Xah Lee. Date: . Last updated: .

here's the syntax for basic arithmetic.

Addition

(* short syntax *)
3+2

(* FullForm syntax *)
Plus[3, 2] 

Substraction

3-2

(* FullForm syntax *)
Plus[3,-2] 

Multiplication

3 * 2

(* FullForm syntax *)
Times[3, 2] 

Multiplication can also be done with a space between numbers.

3 2
(* 6 *)

Division

3/2.
(* 1.5 *)

(* FullForm syntax *)
Times[3, Power[2., -1]]
(* 1.5 *)

(* 3/2 return as is. when integer is divided by another integer, result is an exact fraction. *)
3/2
(* 3/2 *)

(* to get approximate number, wrap it with N[] *)
N[3/2]
(* 1.5 *)

Power

3^2

(* FullForm syntax *)
Power[3, 2] 

Remainder, modular arithmetic

(* remainder, or modular arithmetic *)
Mod[5, 2] 

Testing even/odd

EvenQ[4]
(* True *)

OddQ[3]
(* True *)

WolframLang, Number