a) One day, Ada is bored, so she writes down all the numbers from 1 to 999, inclusive. How many digits did Ada write, in total?
b) If she chooses one of these digits at random, what is the probability that it is a 7?
c) What is the sum of all the digits that Ada writes down?
I got part a) and I kind of know how to start on part b) but I don't know how to do part c). Please help!
For (b), there are 3*9*8 = 216 numbers that have one 7, 3*9 = 27 numbers that have two 7s, and one number that has three 7s, so there are a total of 1*216 + 2*27 + 3*1 = 273 sevens among all the numbers. Divide this by your answer to part (a), and you'll get the probability.
a=999;b=1;c=1;s=0;p=0;b=c;cycle:s=s+(b%10);b=int(b/10);if(b!=0, goto cycle, 0);c++;if(c<=a, goto5,0);print"Total Sum =",s;d=int(log(a)+0.1)+1;f=1;c=1;e=(a-c+1)*d;loop:e=e-(9*(d-f)*10^(f-1)); f++;if(f<=d, goto loop, 0);print"Total Num =",e
Total Sum = 13500
Total Num = 2889
There are 300 7s between 1 and 999 (counting the repeats such as 77, 777......etc).
So, the probability that a random digit will be a 7 is:
300 / 2889 =~ 10.38 %.
Note: This is NOT a mathematical answer but a computer code generated answer!! Just do simple counting like this: 1+2+3+4......9 =45 + 45 * 9 (for ones digits) + 45 * 10 (for tens digits) =900 between 1 and 99....etc.