This post is to link all the methods for solving this problem, but here I will not write the solution but I will explain the mathematics behind the each method. Also I will provide you with the link to the solution which I have already written under each method I will state. Here it should be noted that the time mentioned at the end of this post is what I have observed on my PC and can be seen If you will execute the function for very long numbers.
Method 1
This method uses the simple technique of start from 1 and divide the given number, next 2 divide the number, and so on till the given number is reached. In the above looping if the number and the iterator number is divisible then increase the counter with 1 and after the complete execution of the program then return the counter value. This counter value will give you the number of divisors of the given number. You can see the program for method 1 here:
Method 2
This method is very simple. You can understand it easily by reading it here:
And to see the program visit the link here: (Note that the explanation of the mathematics behind the program and also the program is on the post page).
Method 3
This method is also simple if you will understand it. You can read about the mathematics behind this program here:
And the program here: (Also note that the mathematics behind this program solving has been given in the post including the program section)
The time of execution for the above methods is as follows
Method 2 > Method 3 > Method 1
This is all about this post and see you in next post.
Run the program and comment below the output you are getting for a given input.
Keywords: matlab function, number of divisors, methods
Run the program and comment below the output you are getting for a given input.
Keywords: matlab function, number of divisors, methods