To find number of terms in A.P
$\frac{last term- first term}{common difference} +1$
The time complexity will depend on both the for loop ,since the second for loop is dependent on the first for loop.So,the for loop will run as below:
Number of terms(approx.)
When i=1 j=1,2,3.......n-1 n/1
i=2 j=1,3,5,7,...n-2 n/2
i=k j=1,1+k,1+2k,1+3k...n-k n/k
:
i=n n/n
So ,total time =n/1+n/2+n/3+.....+1
n(1/1+1/2+1/3+......+1/n)
1+1/2+1/3+....1/n <-----logarithmic series =log n
Hence,time complexity=O(nlogn)