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

# Implements f_1
def fun1(n):
    return abs((n ** 2) - 2)

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

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

# Design Question
# 
# Yes, this is a good approach.  The function fun4 is more general and
# more useful than fun3, but not any harder to write.  And fun3 can be
# immediately defined in terms of fun4:
# 
#   def fun3(n):
#       return fun4(5,1,n)
# 
# Testing Question
# 
#   Inputs   Expected Output
#       10                98
#        1                 1
#        0                 2
#       -1                 1
#      -10                98
