According to the formal definition, the approximation of Machine Epsilon is as follows
epsilon = 1.0;
while (1.0 + 0.5 * epsilon) ≠ 1.0:
epsilon = 0.5 * epsilon
Extending this to n, it can be rewritten as
epsilon = 1.0; % Default datatype is double
while(n + 0.5*epsilon ~= n)
epsilon = 0.5*epsilon;
end