Test Informed Learning with Examples

Logo

Repository with assignments using the Test Informed Learning with Examples (TILE) method to integrate testing into existing programming courses for free.

Menu

Calculating the sum of the integers

Write a program to calculate the sum of the integers between \(N\) and \(M\), where \(N\) and \(M\) are values entered by the user. result = \(\sum_{n = N}^{M} n\)

>>> %Run 
    Enter a number: 0
    Enter a number: 3
    The sum from 0 to 3 is:  6
>>> %Run 
    Enter a number: -5
    Enter a number: 3
    The sum from -5 to 3 is: -9
>>> %Run 
    Enter a number: -8
    Enter a number: 8
    The sum from -8 to 8 is:  0
>>> %Run 
    Enter a number: 4
    Enter a number: 4
    The sum from 4 to 4 is:  4
Insist that the students test their programs by giving them example
test executions.