You can treat it as an arithmetic sequence, so multiply the average integer value by the number of integers:
(40+12)/2 × (40 -12 +1) = 26×29 = 754
You can subtract the sum of integers 1–11 (66) from the sum of integers 1–40 (820) to get the sum of integers from 12–40: 820 - 66 = 754.
You can let a graphing calculator do it. (See attached.) This method takes perhaps the least amount of thought. It, too, gets a sum of 754.