Divisors is important when finding NOD, SOD, LCD or GCD etc. The sieve approach to the problem is following:
Now what is the time complexity of above program? . But why? shouldn’t this be . No. Even if there seems to be two loop, the complexity will be because,
For each there will be numbers of divisors. And this will give the harmonic sum:
In some problem the list of divisors are not needed. Instead they require NOD -> Number of Divisors
or SOD -> Summation of Divisors
.
The following formulas of Prime Factorial
is pretty handy:
Example: