Sum of all subsets of a set formed by first n natural numbers | PHP program to find sum of all subsets of a set ; sum of subsets is ( n * ( n + 1 ) / 2 ) * pow ( 2 , n - 1 ) ; Driver Code
< ? php function findSumSubsets ( $ n ) { return ( $ n * ( $ n + 1 ) / 2 ) * ( 1 << ( $ n - 1 ) ) ; } $ n = 3 ; echo findSumSubsets ( $ n ) ; ? >