Here are some useful sub-routines addressing mathematical issues.
Is a Passed Number an Odd Number?
This simple sub-routine will determine whether a passed whole number is even or odd. A returned value of false indicates the passed number is even, a returned value of true indicates the passed number is odd.
Here's an example script using this sub-routine:
display dialog "Enter an even integer:" default answer ""
if the text returned of the result is not "" then ¬
set the requested_number to the text returned of the result as integer
if is_odd(the requested_number) is false then exit repeat
if this_number mod 2 is not 0 then