Given a number n, the task of the programmer is to print the factors of the number in such a way that they occur in pairs. A pair signifies that the product of the pair should result in the number itself;
Input : 24 Output : 1*24 2*12 3*8 4*6 Input : 50 Output : 1*50 2*25 5*10
The simplest approach for this program is that we run a loop from 1 to the square root of N and print and print ‘i’ and ‘N%i’ if the number N is dividing ‘i’.
The mathematical reason why we run the loop till square root of N is given below:
If a*b = N where 1 < a ≤ b < N
N = ab ≥ a^2 ⇔ a^2 ≤ N ⇔ a ≤ √N
1*24 2*12 3*8 4*6
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Print all numbers whose set of prime factors is a subset of the set of the prime factors of X
- Maximum number of prime factors a number can have with exactly x factors
- Find number of factors of N when location of its two factors whose product is N is given
- Check if a number exists having exactly N factors and K prime factors
- Efficient program to print all prime factors of a given number
- Efficient program to print the number of factors of n numbers
- C Program for efficiently print all prime factors of a given number
- Java Program for efficiently print all prime factors of a given number
- Generate K co-prime pairs of factors of a given number
- Number of factors of very large number N modulo M where M is any prime number
- Print all prime factors and their powers
- Print all combinations of factors (Ways to factorize)
- Program to find all Factors of a Number using recursion
- Super Ugly Number (Number whose prime factors are in given set)
- Number with maximum number of prime factors
- Queries on sum of odd number digit sums of all the factors of a number
- Number which has the maximum number of distinct prime factors in the range M to N
- Number of elements with odd factors in given range
- Find minimum sum of factors of number
- Maximum number of unique prime factors
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : chitranayal