一行代码解决,nlog(n)解法
return ''.join([str(i) for i in range(1, n+1)]).count('1')