Product of all Subsets of a set formed by first N natural numbers | Java implementation of the approach ; Function to find the product of all elements in all subsets in natural numbers from 1 to N ; Driver Code
class GFG { static int product ( int N ) { int ans = 1 ; int val = ( int ) Math . pow ( 2 , N - 1 ) ; for ( int i = 1 ; i <= N ; i ++ ) { ans *= ( int ) Math . pow ( i , val ) ; } return ans ; } public static void main ( String [ ] args ) { int N = 2 ; System . out . println ( product ( N ) ) ; } }