I asked this question on programmers 10 days back but wasn't able to get the answer that I wanted.
Write program in java to print the squares of first 25 integers(1-25) without using any variables.
I am not looking for any theory explaining concepts about java or functional programming. I just want to know if its possible in java, the way the author has described in the original context.
--------Edit-------------------- Actually making it mutable variable makes it quite easy. The original context was
(take 25 (squares-of (integers))) Notice that it has no variables. Indeed, it has nothing more than three functions and one constant. Try writing the squares of integers in Java without using a variable. Oh, there’s probably a way to do it, but it certainly isn’t natural, and it wouldn’t read as nicely as my program above.
So try writing same program without using any variables.
printsq(from, to) { print(from*from); if (from < to) printsq(from+1, to); }
\$\endgroup\$