PROBLEM LINK: Divisors
Knowledge of General Mathematics, Basic Programming
- Given the number, we find the factors of that number from 1 to the number itself.
- Now if factors are both odd and even, we find the sum of all odd and even numbers and store the value in sum_pos and sum_neg respectively.
- Now we find the difference between the sum_pos and sum_neg all the while making sure that the difference is positive.
For Example: If the number is 18, its factors (NOTE: Not only prime factor…Instead All the factors) are 1, 2, 3, 6, 9 and 18. Here 1, 3, 9 are odd. And 2, 6 and 18 are even factors. The sum_pos=2+6+18=26 and sum_neg=1+3+9=13. The difference between sum_pos - sum_neg = 26-13=13.
Our answer is 13.