We know that 4-bit unsigned integers range from 0000 to 1111 in binary numeral system (see http://www.cs.uwm.edu/classes/cs315/Bacon/Lecture/HTML/ch04s10.html).
"0000_2 = 0_{10}, \\;\\; 1111_2= (2^3+2^2+2^1+2^0)_{10} = 15_{10}."
Therefore, there are 16 numbers from 0 to 15.
We know that the sum of numbers from 1 to n can be calculated as "\\dfrac{n(n+1)}{2}" (see https://en.wikipedia.org/wiki/1_%2B_2_%2B_3_%2B_4_%2B_%E2%8B%AF). So the sum of integers from 0 to 15 will be
"0 + \\dfrac{15\\cdot16}{2} = 120"
Comments
Dear EVELYN, You are welcome. We are glad to be helpful. If you liked our service, please press a like-button beside the answer field. Thank you!
thanks
Leave a comment