Elim Qiu on Sat, 16 Sep 2017 17:19:07 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: how to define a function with loop


Very nice!
Thanks a lot Karim Belabas !

On Sat, Sep 16, 2017 at 8:54 AM, Elim Qiu <elim.qiu@gmail.com> wrote:
I'd like to define a function returns the decimal approximation of

(1^n+2^n+...+n^n)/(n^n)

In python i have

def tm(n,k):
    return exp(n*log((k+0.0)/n))

def sm(n,m):
    s = 0.0
    for j in range(m):
        k = n -j
        s += tm(n,k)
    return s

How do I put a loop inside of a definition of pari function?

Thanks