text: Count divisors of array multiplication | A simple C ++ program to count divisors in array multiplication . ; To count number of factors in a number ; Initialize count with 0 ; Increment count for every factor of the given number X . ; Return number of factors ; Returns number of divisors in array multiplication ; Multipliying all elements of the given array . ; Calling function which count number of factors of the number ; Driver code
code: #include <iostream> NEW_LINE using namespace std ; int counDivisors ( int X ) { int count = 0 ; for ( int i = 1 ; i <= X ; ++ i ) { if ( X % i == 0 ) { count ++ ; } } return count ; } int countDivisorsMult ( int arr [ ] , int n ) { int mul = 1 ; for ( int i = 0 ; i < n ; ++ i ) mul *= arr [ i ] ; return counDivisors ( mul ) ; } int main ( ) { int arr [ ] = { 2 , 4 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countDivisorsMult ( arr , n ) << endl ; return 0 ; }