java - Factor table algorithm with complexity O(n·sqrt(n)) -


the following code prints table of factors of each number 0 n. can me rewrite following o(n²) time code has complexity o(n·sqrt(n)) time ?

i rewrote algorithm have o(n·log n) can't figure out complexity.

public static vector<vector<integer>> facttable(int n) {   vector<vector<integer>> table = new vector<vector<integer>>();   (int = 1;i <= n; i++) {     vector<integer> factors  =  new  vector<integer>();      (int  f  =  1;  f  <=  i;  f++) {       if  ((i  %  f)  ==  0)         factors.add(f);     }   table.add(factors);   }   return  table; } 

for each factor f of i, i/f factor of i.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -