CS8 Programming Assignment 1

CS8 Programming Assignment 1

Write a function called Adder(i, j) which takes two integers i and j as input, computes the sum from i (included) to j (included) if i ≤ j. Otherwise Adder(i, j) outputs zero.
For example, Adder computes and returns the following:
  • Adder(5, 4) → 0 (since 5 > 4)
  • Adder(5, 5) → 5 (since we have just 5)
  • Adder(5, 6) → 11 (since 5+6 = 11)
  • Adder(5, 7) → 18 (since 5+6+7 = 18)
  • Adder(1, 5) → 15 (since 1+2+3+4+5 = 15)
Write your function in a Python text file named pa1.py, and turn in your assignment via Dropbox (see the course website for details).


cs8 Web Site