Problem 42791. Number of divisors of a given number
Solution Stats
Problem Comments
-
6 Comments
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!
Solution Comments
-
1 Comment
It is not good idea to use arrays from 1 to n.
-
1 Comment
nice! really nice.
Problem Recent Solvers44
Suggested Problems
-
13408 Solvers
-
middleAsColumn: Return all but first and last element as a column vector
485 Solvers
-
Create matrix of replicated elements
340 Solvers
-
3407 Solvers
-
Natural numbers in string form
761 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!