First approch with negative numbers

when we give negative numbers for first aproch it fails to count because we are using n>0 in while loop condition for eg -1 has all ones