#Matlab Note that `a = n^2` iff `log(a) = log(n)*2` iff `log(log(a)) = log(log(n))+log(2)`. So this function is just finding the zero of the function `f(a) = log(log(n))+log(2) - log(log(a))` which obviously is at `a = n^2`. function s = g(n) f = @(a) log(log(n))+log(2)-log(log(a)); s = fnzeros(f); end ### Here some other not very creative functions: Here the program wil sum sum the number `1+2+3+...+n = 1/2 * (n^2+n)` twice and substract `n`, so the result is always `n^2` g=@(n)sum(1:n)+sum(1:n)-n This function creates a `n x n` matrix of random numbers (between 0 and 1) and then returns the number of elements. g=@(n)numel(rand(n)); The following functin creates a [vandermonde matrix][1] of the vector `(0,0,n)` and outputs the entry that consists of `n^2` function s = g(n) a = vander([0,0,n]); s = a(3,1) end This function creates the inverse of a [hilbert matrix][2] of size `n` where the top left element is always `n^2` function s = g(n) a = invhilb(n); s = a(1); end [1]: http://de.wikipedia.org/wiki/Vandermonde-Matrix [2]: http://en.wikipedia.org/wiki/Hilbert_matrix