How to determine if a number is even or odd with AMPScript?
I'd suggest using the MOD() AMPScript function. If @sum
is evenly divisible by 2 then it's even, otherwise it's odd:
%%[
var @i, @sum, @max
set @sum = 0
set @max = 10
FOR @i = 1 TO @max DO
SET @sum = Add(@sum,1)
NEXT @i
IF mod(@sum,2) == 0 THEN
outputline(concat("<br>", @sum, " is even"))
ELSE
outputline(concat("<br>", @sum, " is odd"))
ENDIF
]%%