# William M. Farmer
# 9 November 2010
#
# This is a solution for Lab 07: Marked Assignment 3 on Monday.

# Implements f_1
def fun1(n):
    return (n ** 3) - 1

# Implements f_2
def fun2(n):
    val = 0
    for i in range(n + 1):
        val = val + (i * fun1(i))
    return val

# Implements f_3
def fun3(m,n):
    list = []
    for i in range(m, n + 1):
        list = list + [fun1(i)]
    return list

# Design Question
# 
# Yes, this is a good approach.  The function fun4 is more general and
# more useful than fun2, but not any harder to write.  And fun2 can be
# immediately defined in terms of fun4:
# 
#   def fun2(n):
#       return fun4(0,n)
#  
# Testing Question
# 
# Only one test case is needed because, when n is negative, 
# 
#   range(n + 1)
# 
# is [] and so the body of the for loop is never executed.  That is,
# fun2 behaves exactly the same for all negative inputs.

