Can this be done efficiently for n as big as 10^8
I think you want the sum of n/1+n/2+n/3+…n/n. Read this editorial Sept’13 Editorial