Given a number n, write a program to calculate number of ways in which number can be expressed as product of two different factors.
Input : 12 Output : 3 12 can be expressed as 1 * 12, 2 * 6 and 3*4. Input : 36 Output : 4 36 can be expressed as 1 * 36, 2 * 18, 3 * 12 and 4 * 9.
All factors of 12 are = 1, 2, 3, 4, 6, 12 We can observe that factors always exist in pair which is equal to number. Here (1, 12), (2, 6) and (3, 4) are such pairs.
As a number can expressed as product of two factors we only need to find number of factors of number upto square root of number. And we only need to find only different pairs so in case of perfect square we don’t include that factor.
This article is contributed by nuclode. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Find number of factors of N when location of its two factors whose product is N is given
- Count ways to express even number ‘n’ as sum of even integers
- Count ways to express a number as sum of exactly two numbers
- Count ways to express a number as sum of consecutive numbers
- Product of factors of number
- Maximize the product of four factors of a Number
- Product of unique prime factors of a number
- Check if a number exists having exactly N factors and K prime factors
- Print all combinations of factors (Ways to factorize)
- Maximum number of prime factors a number can have with exactly x factors
- Find four factors of N with maximum product and sum equal to N | Set-2
- Distinct Prime Factors of Array Product
- Find four factors of N with maximum product and sum equal to N
- Find four factors of N with maximum product and sum equal to N | Set 3
- Find the row whose product has maximum count of prime factors
Improved By : jit_t