Product of all Subsets of a set formed by first N natural numbers | C ++ implementation of the approach ; Function to find the product of all elements in all subsets in natural numbers from 1 to N ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int product ( int N ) { int ans = 1 ; int val = pow ( 2 , N - 1 ) ; for ( int i = 1 ; i <= N ; i ++ ) { ans *= pow ( i , val ) ; } return ans ; } int main ( ) { int N = 2 ; cout << product ( N ) ; return 0 ; }