When the script is started, it displays "Enter the number of Diversity" and expects an input. The range and type of valid inputs are not explained in the help text, such that the user has to examine the poorly documented code to see, what this number should represent at all.
Why do you measure the timings by TIC/TOC?
Instead of the loop, the command MAX() is much faster to determin the maximum.
Currently the purpose of the program is not clear.