Given a Number n, return the number of his divisors without listing them
example:
n=14 ; Divisors={1,7,2,14} ; y=4
n=68 ; Divisors={1,2,34,17,4,68} ; y=6
Solution Stats
Problem Comments
6 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers67
Suggested Problems
-
Return a list sorted by number of occurrences
2897 Solvers
-
Generate a vector like 1,2,2,3,3,3,4,4,4,4
14144 Solvers
-
Put Two 1D matrices into one 1D matrix
142 Solvers
-
Is this triangle right-angled?
6731 Solvers
-
Find the dimensions of a matrix
565 Solvers
More from this Author12
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
It would be better to add squared integer numbers n in the test suite, in which case, the number of divisors is odd. However, the test suite only contain non-squared integer n, in which case the number of divisors is always even.
Any particular reason why sqrt is forbidden?
The divisors are symmetric about sqrt(n). I guess the intention to forbid sqrt might be to eliminate brute-force search approaches, which need to search over 1~sqrt(n).
Peng Liu ,thanks for the suggestion.I added a few tests.
James, the reason sqrt is forbidden is what Peng Liu suggested.
Hey, this problem is essentially the same as problem 2664 by Jean-Marie.
Good catch!