sum func

Here is my solution for one of the first homework problems in CSci 1901, but in Python.

def sumfunc(a, b, c):
    if a >= c and b >= c:
        return (a + b) / c
    else:
        return sumfunc(b, c, a)

print sumfunc(8, 6, 2)
print sumfunc(3, 5, 4)
print sumfunc(9, 9, 9)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s