Python中的while循环语句,求解

.求下面数列的值,x用户输入,x-x/2!+x/3!-x/4!...+(-1)^(n+1)x/n!+...,
要求:末项绝对值要大于10^(-4)
请输入x=1
结果表达式的和为:0.6321428571428571

def fact(n):
    res = 1
    for i in range(1,n+1):
        res *= i
    return res

def Sum(x):
    res = 0.0
    n = 1
    while abs(x*(-1)**(n+1)/fact(n))>10**(-4):
        res += x*(-1)**(n+1)/fact(n)
        n += 1
    return res

Sum(1)

输出:
0.6321428571428571