WolframLang: Arithmetic Basics

By Xah Lee. Date: . Last updated: .

here's the syntax for basic arithmetic.

Addition

(* short syntax *)
3+2 === 5

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

Substraction

3-2 === 1

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

Multiplication

3 * 2 === 6

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

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 === 3/2

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

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

Power

3^2 === 9

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

Remainder, modular arithmetic

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

Testing even/odd

EvenQ[4] === True

OddQ[3] === True

Number