calculate the total occurances of 1 from 1~n