We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Sherlock and Divisors
Sherlock and Divisors
Sort by
recency
|
168 Discussions
|
Please Login in order to post a comment
Python golfing, 3 lines, O(sqrt(n))
Bonus optimizations with bithacks which bring down runtime a lot but still same asymptotic worst case:
The idea is to first extract the number of 2 factors from N, then find the number of factors of the now-odd N and do some basic combinatorics to come up with the answer.
c#
public static int divisors(int n)
great
Python 3
Java 8