Number of Symmetric Relations on a Set | C ++ 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
#include <bits/stdc++.h> NEW_LINE unsigned int countSymmetric ( unsigned int n ) { if ( n == 0 ) return 1 ; return 1 << ( ( n * ( n + 1 ) ) / 2 ) ; } int main ( ) { unsigned int n = 3 ; printf ( " % u " , countSymmetric ( n ) ) ; return 0 ; }