Sum of product of all subsets formed by only divisors of N | Function to find the sum of product of all the subsets formed by only divisors of N ; Vector to 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
def GetSum ( n ) : NEW_LINE INDENT divisors = [ ] NEW_LINE i = 1 NEW_LINE while i * i <= n : NEW_LINE INDENT if ( n % i == 0 ) : NEW_LINE INDENT divisors . append ( i ) NEW_LINE if ( i != n // i ) : NEW_LINE INDENT divisors . append ( n // i ) NEW_LINE DEDENT DEDENT i += 1 NEW_LINE DEDENT ans = 1 NEW_LINE for i in divisors : NEW_LINE INDENT ans *= ( i + 1 ) NEW_LINE DEDENT ans = ans - 1 NEW_LINE return ans NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = 4 NEW_LINE print ( GetSum ( N ) ) NEW_LINE DEDENT