If the numbers 1 to 5 are written out in words: one, two, three, four, five,
then there are
letters used in total.
If all the numbers from 1 to 1000 (one thousand) inclusive were written out
in words, how many letters would be used?
NOTE: Do not count spaces or hyphens. For example,
342 (three hundred and forty-two) contains 23 letters and 115 (one hundred and
fifteen) contains 20 letters. The use of "and" when writing out numbers is
in compliance with British usage.
I made arrays with the numbers spelled out. One for the ones (9 elements),
one for the teens (10 elements), one for the tens (8 elements), and one
for the hundreds (9 elements).
I used 4 for loops to cycle through the numbers and count up the characters
in the strings as I went along.
###,###