CS8 Programming Assignment 1

CS8 Programming Assignment 1

Write a function called Adder(i, j, k) which takes three integers i, j, and k as input, computes the sum from i**k (i included) to j**k (j included) if i ≤ j, where i, j, k are always ≥ 0. If i > j, then Adder(i, j, k) outputs zero. For example, Adder computes and returns the following:
  • Adder(5, 4, 2) → 0 (since 5 > 4)
  • Adder(5, 5, 1) → 5 (since we have just 5**1)
  • Adder(5, 6, 2) → 61 (since 5**2+6**2 = 25+36 = 61 )
  • Adder(5, 7, 3) → 684 (since 5**3+6**3+7**3 = 684)
  • Adder(1, 5, 1) → 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