It takes 1629 digits to number the pages of a book. How many pages does the book have?
From numbers 1-9, 9 digits are used. From numbers 10-99, 90*2=180 digits are used. From numbers 100-999, 900*3=2700 digits are used. The number of pages in this book must fall somewhere between 100-999. We already have 180+9=189 digits.
1629-189=1440.
We divide 1440 by 3 to find the number of pages between 100-999. We get 480 pages.
n=579;m=1;r=n;s=0;d=0; c=1;p=0;cycle1:s=s+n%10;d=d+1;n=int(n/10);if(n!=0, goto cycle1, 0); p=(r-m+1)*d;loop1:p=p-(9*(d-c)*10^(c-1) ;c++;if(c<=d, goto loop1, 0);print"Total Num =",p;print"Total Sum =",;
OUPUT: 1629 pages is the number of pages from 1 to 579 inclusive. Therefore, the book has 579 pages.