% function a = nested_sqrt(n)
% a = 1;
% for j=n:-1:2
%     a = sqrt(1 + j*a);
% end
function a = nested_sqrt(n)
%takes a number n and returns a
    a= (n-1)* sqrt(1+n);
    for j= n-2:-1:1
        n = n-1;
        a = (n-1)* sqrt(1+a);


    end
    if n == 1, a = 1; end
end
  


