Optimize this Python code to achieve better performance.
def functionA(x):
    answer = 0
    for i in range(x):
        for j in range(i+1):
            answer += 1
    return answer
def functionA(x):
    answer = 0
    for i in range(x):
        answer += x-i
    return answer