Since you've answered it yourself, I'll add my 2-bits with a little visual explanation on how you can avoid retaining the count in a variable and passing it as a parameter in your recursive method.
Discalimer: I'm using Java's array indexing convention since problem statements like yours may not be language specific and indexing a Java array from 1-n as opposed to 0-(n-1) makes little sense due to the extra elements required to do so. With that said, I assume they mean an array consists of n elements which fill the array. I also start at the beginning of the array and work towards the end; there's no difference in this regard because in either case the stack unwinds to return the value to the caller.
My crude drawing below is pretty self-explanatory. The |_..._|s show the values that are being compared with the associated recursive method calls. On the first call we check for the base case and if not met we call the method again with the next index; we continue to do so until we reach the base case (n == A.length). Once we reach the end we return 0 to the previous call which returns its value plus the next call's value (the ongoing count). We continue doing this until we return to the caller.
0 1 2 3 : indices
-------------------
3 5 3 6 : values
|_____| | |
|___________| |
|_________________|
<--------2| <--1| <--1| <--0| : return values
-------------------------
1 2 3 4 : call stack (4 = base case)
Here's the code that does just that:
static int numGreater(int[] A, int n) {
if (n == A.length) return 0;
return (A[0] < A[n] ? 1 : 0) + count(A, n + 1);
}
Now you should be able to see that each method call that is not the base case will add 1 or 0 to the next call based on the A[0] < A[n] condition thereby accumulating the count as the stack unwinds making the count variable unnecessary.
Note that you should also be able to see why checking for equality between the first and i-th element will not work due to the fact it could short circuit the recursion resulting in an incorrect count.
ifexpression supposed to do, and why do you think that expression does that?