# Lab 4
# YOUR NAMES HERE

import math

# compute 1 + 2 + 3 + ... + n
# use for loop and range function
def sum(n):
    return None

# returns 1x1 + 2x2 + 3x3 + 4x4 + ... + nxn 
# use for loop and range function
def sumSquares(n):
    return None

# returns 1 + 3 + 5 + ... + 2*n-1 
# use for loop and range function
def sumOdds(n):
    return None

# compute n! = 1 x 2 x 3 x ... x n
# use for loop and range function
# don't use any math library functions
def factorial(n):
    return None

# return 2 to the nth power
# use for loop and range function
# don't use any math library functions
# dont use the ** operator
def p2(n):
    return None

# returns 1 + 2 + 4 + 8 + 16 + ... + 2**n 
# use for loop and range function
# don't use any math library functions
def p2sum(n):
    return None

# return x to the nth power
# use for loop and range function
# don't use any math library functions
# dont use the ** operator
def power(x, n):
    return None

# returns an approximation to pi using n terms
# use for loop and range function
def pi(n):
    return None

# returns x**k/k!
# use for loop and range function
# don't use any math library functions
# dont use the ** operator
# dont use your factorial or power functions
def term(x, k):
    return None

# returns approximation to the sine of x using n terms
# use for loop and range function
# don't use any math library functions
# dont use the ** operator
# dont use your factorial or power functions
# use your term function
def sin(x, n):
    return None

# returns approximation to the cosine of x using n terms
# use for loop and range function
# don't use any math library functions
# dont use the ** operator
# dont use your factorial or power functions
# use your term function
def cos(x, n):
    return None

# returns the nth Fibonacci number
# 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144
# fibo(0) = 0
# fibo(1) = 1
# fibo(2) = fibo(1) + fibo(0)
# fibo(3) = fibo(2) + fibo(1)
# fibo(4) = fibo(3) + fibo(2)
# use a while loop, no recursion
def fibo(n):
    return None

# A zoologist orders a shipment of animals.
# The shipment contains spiders (S), beetles (B), mice (M), and canaries (C).
# The shipment contained a total of n legs. How many of each animal is present?
# Count the number of solutions to this problem: 8S + 6B + 4M + 2C = n
# use nested for loops
def legs(n):
    return None


# Testing code
def main():
    print("sum")
    print(sum(10), "should be 55")
    print(sum(100), "should be 5050")
    print()
    
    print("sumSquares")
    print(sumSquares(1), "should be 1")
    print(sumSquares(5), "should be 55")
    print()
    
    print("sumOdds")
    print(sumOdds(1), "should be 1")
    print(sumOdds(10), "should be 100")
    print()
    
    print("factorial")
    print(factorial(0), "should be 1")
    print(factorial(1), "should be 1")
    print(factorial(5), "should be 120")
    print(factorial(20), "should be 2432902008176640000")
    print()
    
    print("p2")
    print(p2(0), "should be 1")
    print(p2(1), "should be 2")
    print(p2(5), "should be 32")
    print(p2(10), "should be 1024")
    print(p2(20), "should be 1048576")
    print()
    
    print("p2sum")
    print(p2sum(0), "should be 1")
    print(p2sum(6), "should be 127")
    print()
    
    print("power")
    print(power(2,3), "should be 8")
    print(power(3,4), "should be 81")
    print(power(6,7), "should be", 6**7)
    print()
    
    print("pi")
    print(pi(1), "should be close to 3.14159265358979323844")
    print(pi(1000), "should be closer to 3.14159265358979323844")
    print(pi(1000000), "should be even closer to 3.14159265358979323844")
    print()

    print("term")
    print(term(3,5), "should be 2.025")
    print()

    print("sin")
    print(sin(math.pi/2,1), "should be close to", math.sin(math.pi/2))
    print(sin(math.pi/2,1000), "should be closer to", math.sin(math.pi/2))
    print()

    print("cos")
    print(cos(math.pi,1), "should be close to", math.cos(math.pi))
    print(cos(math.pi,1000), "should be closer to", math.cos(math.pi))
    print()

    print("fibo")
    print(fibo(0), "should be 0")
    print(fibo(1), "should be 1")
    print(fibo(2), "should be 1")
    print(fibo(7), "should be 13")
    print(fibo(12), "should be 144")
    print()

    print("legs")
    print(legs(0), "should be 1")
    print(legs(1), "should be 0")
    print(legs(8), "should be 5")
    print(legs(100), "should be 1154")
    print()

main()
