Poor or Repetitive Logic

Consider the code below:


 1. Poor or repetitive logic - An example of poor logic would be when the programmer is asked to sum the first 1,000,000 numbers and does the following:


for i in range (1000001):

    total = total + i



Instead he/she should take the well-known mathematics short cut of (1,000,000 * 1,000,001)/2 = 500,000,500,000.