Adjusted method of calculation on problem 12, uses built-in functions.