For f to be ONTO, we must have that for all y in integers, there exist some x in integers such that
f(x) = y
if a = -1 then f(x) = -x + b. So if y is an integer, then if we take x = - y + b, then f(x) = y. Thus f is ONTO. Similarly for a = +1.
Suppose a is neither +1 not -1, then take y = b + 1. If there exists such an x, then ax+ b = y = b+ 1. Therefore ax = 1. But we know that ax = 1 is possible [a, x in integers] if and only if a = +1 or -1. Thus we have a contradiction. Hence there is no such x and f is NOT ONTO in this case.
Answers & Comments
Verified answer
For f to be ONTO, we must have that for all y in integers, there exist some x in integers such that
f(x) = y
if a = -1 then f(x) = -x + b. So if y is an integer, then if we take x = - y + b, then f(x) = y. Thus f is ONTO. Similarly for a = +1.
Suppose a is neither +1 not -1, then take y = b + 1. If there exists such an x, then ax+ b = y = b+ 1. Therefore ax = 1. But we know that ax = 1 is possible [a, x in integers] if and only if a = +1 or -1. Thus we have a contradiction. Hence there is no such x and f is NOT ONTO in this case.