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.
It is not good idea to use arrays from 1 to n.
nice! really nice.
Remove the vowels
First non-zero element in each column
Back to basics 19 - character types
Generate a string like abbcccddddeeeee
Compute LOG(1+X) in natural log
How many rectangles in a grid ?
Speed of light:Experiment
Slicing the cube
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office