How many letters in this word?
Python 2, 266 259 236 229 228 bytes



This works for all inputs below one billion. This works for all test cases.

def l(n):b=[6,3,2][(n&lt;1000)+(n&lt;10**6)];c=10**b;return int("0335443554"[n%10])+int("0366555766"[n/10])+(n-10in[4,6,7,9])if n&lt;100else l(n/c)+(l(n%c)or-3*(b&lt;3))+7+(b&lt;6)+2*(b&lt;3)+3*(b&gt;2)*(0&lt;n%c&lt;101)
print sum(map(l,range(input()+1)))


To modify it to fit the question as stated (e.g. don't treat numbers ending with 100 special) simply replace the number 101 at the end of the first line with 100.

Explanation:

def l(n):
    b=[6, 3, 2][(n &lt; 1000) + (n &lt; 10**6)] # b = 2 if n &lt; 1000 else 3 if n &lt; 1000000 else 6
    c=10**b
    return (                            # Parenthesis added for readability.
            int("0335443554"[n % 10]) + # Compute length of last digit. one -&gt; 3, seven -&gt; 5, etc.
            int("0366555766"[n / 10]) + # Compute length of second to last digit. ten -&gt; 3, eighty -&gt; 6, etc.
            (n - 10 in[4, 6, 7, 9])     # Add one to length if the number is 14, 16, 17, or 19.

            if n &lt; 100 else             # Use above procedure if the number is under 100.
                                        # If otherwise, use below procedure.

            l(n / c) +                  # Compute length of the top portion of number.
                (l(n % c) or            # Compute length of bottom portion of number.
                -3 * (b &lt; 3)) +         # If the number &lt; 1000 and is a multiple of 100,
                                        # subtract 3 from the length because of missing and.
            7 +                         # Add 7 to the length for "million"
            (b &lt; 6) +                   # Add 8 to the length for "thousand"
            2 * (b &lt; 3) +               # Add 10 to the length for "hundred and"
                3 *                     # Add 3 to the length for another "and"
                (b &gt; 2) *               # if the number &gt;= 1000
                (0 &lt; n % c &lt; 101)       # and the bottom portion &gt; 0 and &lt;= 100
    )
print sum(map(l,range(input()+1)))      # For the reader to figure out.