It would be better for ‘answer’ to be local to the handler:
on fac(theNum)
set answer to 1
repeat with i from 1 to theNum
set answer to answer * i
end repeat
return answer
end fac
fac(5) -- returns 120, every time!
Another thing, I suppose, is that the first iteration of the repeat (multiplying 1 by 1) is superfluous. You could repeat with i from 2 to theNum. If theNum is 1, the repeat simply won’t be executed.