MATLAB: Is N not being displayed

displayfor loop

My problem: I am trying to find the smallest value of N for which error is less than 10^-4. I am just wondering why N is not being displayed at the end of the code.
N=10;
error=1;
while error<10^-4
N=N+1;
sum=0;
for n=1:N
y=1/n^2;
sum=sum+y;
end
error=((pi^2)/6)-sum;
disp(N)
end

Best Answer

Because the loop condition is never satisfied and therefore nothing within it is ever executed. I think you meant to have,
while error>10^-4