Factors are paired. 1
and 24
, 2
and 12
, 3
and 8
, 4
and 6
.
An improvement of your algorithm could be to iterate to the square root of num
instead of all the way to num
, and then calculate the paired factors using num / i
.
More Related Contents:
- Creating all possible k combinations of n items in C++
- Finding all the subsets of a set
- Fast ceiling of an integer division in C / C++
- Most efficient/elegant way to clip a number?
- Fastest algorithm for primality test [closed]
- Special simple random number generator
- sine wave that slowly ramps up frequency from f1 to f2 for a given time
- Inverting a 4×4 matrix
- Fastest way to get the integer part of sqrt(n)?
- Finding square root without using sqrt function?
- How to find number of words in a phrase with spaces removed by checking v. dictionary
- How to find out the date of the first day of week from the week number in C++
- How approximation search works
- What is the efficient way to count set bits at a position or lower?
- Fast exact bigint factorial
- Generating combinations in c++
- Representing 128-bit numbers in C++
- Finding duplicates in O(n) time and O(1) space
- Fast String Hashing Algorithm with low collision rates with 32 bit integer [closed]
- Emulate “double” using 2 “float”s
- Need for predictable random generator
- Iterative DFS vs Recursive DFS and different elements order
- Searching in a sorted and rotated array
- `std::list::sort()` – why the sudden switch to top-down strategy?
- What are the most widely used C++ vector/matrix math/linear algebra libraries, and their cost and benefit tradeoffs? [closed]
- How can I sort an STL map by value?
- What is the safe way to fill multidimensional array using std::fill?
- Algorithm for Calculating Binomial Coefficient
- Calculate mean and standard deviation from a vector of samples in C++ using Boost
- Checking if all elements of a vector are equal in C++