Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

exponent of a prime

I am newbie in SAGE and here. My apologies for any mistake. This is an easy question.

Is there a command that for an integer $m$ and a prime number $p$ returns the exponent of $p$ in $m$?

If not, I would like if the following definition can be improved.

def exponent(p,m):
    v=m
    sol=0
    while v%p==0:
        v=v/p
        sol=sol+1
    return sol

Thanks.

exponent of a prime

I am newbie in SAGE and here. My apologies for any mistake. This is an easy question.

Is there a command that for an integer $m$ and a prime number $p$ returns the exponent of $p$ in $m$?

If not, I would like if the following definition can be improved.

def exponent(p,m):
    v=m
    sol=0
    while v%p==0:
        v=v/p
        sol=sol+1
    return sol

Thanks.