The loop can be run till num/2 only and the result with be same cause if a value can't be divided by it's half then it will only be divided by num itself. For example: if 17 can't be divided by 8 then there is no chance that it can be divided by 9,10 or 16 even, it will be divided by 17 only.
@@mukeshprajapati5515 A much better solution still does exist. this solution does not affect the time complexity much because constant factors are neglected during calculation. hence O(n*n/2) is same as O(n^2)
@@mukeshprajapati5515 A better solution still exists. this solution doesn't affect the time complexity much because during calculation constant factors are neglected hence O(n*n/2) is same as O(n*n)