20 December 2020

1. 100

2. 150

3. 125

4. 200

# Coding Question

You are given an integer N. You have to count how many possible combinations of numbers from 1 to N (excluding 1 and N). which are dividing the number N and after multiplication exactly equal to the value N.

For Example: Let suppose, I have a number 12 and the number that divides 12 between 1 to 12 are 2, 3, 4, 6 we can form N by multiply 26, 34 and 223. So, there are 3 possible combinations for number 12. Note: We will not consider 1 and N we will try to find the combinations in between them.

`Sample Input:312832​Sample Output:326​Explanation:For test case 1: For value 12 we have 3 combinations in total.[ [2, 6], [2, 2, 3], [3, 4] ]​For test case 2: For value 8 we have only 2 combinations:[ [2, 2, 2] , [2, 4] ]`

# Solution:

`int getFactors(int n) {    if(n<=3) return 0;    vector<int>v;    for(int i=2;i<=sqrt(n);i++)    {        if(n%i==0)        {v.push_back(i);        if(n%(n/i)==0 && n/i!=i)        v.push_back(n/i);        }    }    sort(v.begin(),v.end());    vector<int>k(n+1,0);    k=1;    for(int i=0;i<v.size();i++)        for(int j=v[i];j<=n;j+=v[i])            k[j]+=k[j/v[i]];    return k[n];}`