Sum of product of all subsets formed by only divisors of N | C # program to find the sum of product of all the subsets formed by only divisors of N ; Function to find the sum of product of all the subsets formed by only divisors of N ; Store all the divisors of n ; Loop to find out the divisors of N ; Both ' i ' and ' n / i ' are the divisors of n ; Check if ' i ' and ' n / i ' are equal or not ; Calculating the answer ; Excluding the value of the empty set ; Driver code
using System ; using System . Collections . Generic ; class GFG { static int GetSum ( int n ) { List < int > divisors = new List < int > ( ) ; for ( int i = 1 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { divisors . Add ( i ) ; if ( i != n / i ) { divisors . Add ( n / i ) ; } } } int ans = 1 ; foreach ( int i in divisors ) { ans *= ( i + 1 ) ; } ans = ans - 1 ; return ans ; } public static void Main ( ) { int N = 4 ; Console . WriteLine ( GetSum ( N ) ) ; } }