Count the number of ways numbers 1,2,…,n can be divided into two sets of equal sum
You are counting the number of ordered pairs of sets $(A,B)$ such that the elements of $A$ (and of $B$) sum to $n(n+1)/4$.
Simply divide the result by $2$ to account for symmetries.

Besides, your algorithm has complexity $\Omega(2^n)$ so I doubt you'll meet the time constraint in the link you provided.

You can get an $O(n^3)$-time dynamic-programming algorithm as follows:


   Let $OPT[n, x]$ be the number of ways the numbers in $\{1, \dots, n\}$ can be partitioned into an ordered pair of sets $(A,B)$ such that the elements of $A$ sum to $x$ and those of $B$ sum to $n(n+1)/2 -  x$. 
 
 

 Then, $OPT[0, 0] = 1$, $OPT[n][x] = 0$ if $n&lt;0$ or $x&lt;0$, and 

 $$OPT[n,x] = OPT[n-1, x-n] + OPT[n-1, x]$$

 Now, assuming that $n(n+1)/2$ is even, the solution you are looking for is: $\frac{1}{2}OPT[n][ n(n+1)/4 ]$.