Number of Symmetric Relations on a Set | Java program to count total symmetric relations on a set of natural numbers . ; function find the square of n ; Base case ; Return 2 ^ ( n ( n + 1 ) / 2 ) ; Driver code
import java . io . * ; import java . util . * ; class GFG { static int countSymmetric ( int n ) { if ( n == 0 ) return 1 ; return 1 << ( ( n * ( n + 1 ) ) / 2 ) ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( countSymmetric ( n ) ) ; } }