# Exercice 10

def a(x, y):
    return x + y
def m(x, y):
    return x * y
def s(x, y):
    return x - y
def d(x, y):
    return x / y
    
def carre(x):
    return m(x, x)
    
def cube(x):
    return m(x, m(x, x))
    
def f(x):
    return s(s(m(2, cube(x)), m(d(4, 3), carre(x))), 9)
    
# avec p positif ou nul
def puis(x, p):
    if x == 0 and p == 0:
        1    # 0**0 == 1 ou 0 en fonction du context... voir wikipédia pour mal de tête
    elif x == 0:
        return 0
    
    res = 1
    for _ in range(p):
        res = res * x
    return res

# avec p relatif    
def puis(x, p):
    if x == 0 and p == 0:
        1    # 0**0 == 1 ou 0 en fonction du context... voir wikipédia pour mal de tête
    elif x == 0:
        return 0
    
    res = 1
    if p > 0:
        for _ in range(p):
            res = res * x
    else:
        for _ in range(-p):
            res = res / x
    return res
    
def fact(n):
    res = 1
    for i in range(2, n+1):
        res = res * i
    return res
