Ticket #11430: trac_11430_pseudoprime.patch

File trac_11430_pseudoprime.patch, 1.2 KB (added by itolkov, 10 years ago)

Updated with commit message, do not use 11430-arith.patch

  • sage/rings/arith.py

    # HG changeset patch
    # User Igor Tolkov <itolkov@gmail.com>
    # Date 1307769306 25200
    # Node ID b058207710984e7ef1e8944dbf0b54f6c27ec4c5
    # Parent  ce324e28c3334398d3552640e2cb1520d22465a3
    Trac 11430: fix bug in is_pseudoprime_small_power with get_data=True
    
    diff -r ce324e28c333 -r b05820771098 sage/rings/arith.py
    a b  
    619619        [(3, 1024)]
    620620        sage: is_pseudoprime_small_power(2^256, get_data=True)
    621621        [(2, 256)]
     622        sage: is_pseudoprime_small_power(31, get_data=True)
     623        [(31, 1)]
    622624        sage: is_pseudoprime_small_power(15, get_data=True)
    623625        False
    624626    """
    625627    n = ZZ(n)
    626     if n.is_pseudoprime() or n == 1:
     628    if n == 1:
     629        # canonical way to write 1 as a prime power?
    627630        return True
    628     if n < 0:
     631    if n <= 0:
    629632        return False
    630     for i in range(2, bound + 1):
     633    if n.is_pseudoprime():
     634        if get_data == True:
     635            return [(n, 1)]
     636        else:
     637            return True 
     638    for i in xrange(2, bound + 1):
    631639        p, boo = n.nth_root(i, truncate_mode=True)
    632640        if boo:
    633641            if p.is_pseudoprime():