I can write x(n) = u(n) - u(n-4), where u(n) is the unit step function.

This this right?

n = -5: u(-5) - u(-5 - 4) = u(-5) - u(-9) = 0 - 0 = 0

thru:

n = -1: u(-1) - u(-1 - 4) = u(-1) - u(-5) = 0 - 0 = 0

These are right, but:

n = 0: u(0) - u(0 - 4) = u(0) - u(-4) = 1/2 - 0 = 1/2

n = 1: u(1) - u(1 - 4) = u(1) - u(-3) = 1 - 0 = 1

n = 2: u(2) - u(2 - 4) = u(2) - u(-2) = 1 - 0 = 1

n = 3: u(3) - u(3 - 4) = u(3) - u(-1) = 1 - 0 = 1

n = 4: u(4) - u(4 - 4) = u(4) - u(0) = 1 - 1/2 = 1/2

Did you define u(0) to be 1

instead of 1/2?
Thus:

f(x(n)) = f(u(n)-u(n-4)) = f(u(n)) - f(u(n-4)) = nu(n) - (n-4)u(n-4).

Is this the same? You started with

Then

IOW, your formula is supposed to be f(x(n)) = n*x(n) = n*[u(n) - u(n - 4)] = n*u(n) - n*u(n - 4). But somehow you got the last term to be (n - 4)*u(n - 4). Shouldn't that first "n - 4" be just "n"?