Skip to content

Commit 9c1da99

Browse files
author
Release Manager
committed
gh-40850: fixing a bug in perfect_power
Fix #40846 ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. URL: #40850 Reported by: Frédéric Chapoton Reviewer(s): Martin Rubey, Sahil Jain, Vincent Macri
2 parents 4e5f1d9 + 5649932 commit 9c1da99

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

build/pkgs/configure/checksums.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
tarball=configure-VERSION.tar.gz
2-
sha1=dacd801ebf4c551ecfc93ae1263f4c0acc79154d
3-
sha256=3d0d90cd76c6a4b8773366e44b459244d6ccef764f69d33a3591e09d7014fc26
2+
sha1=768af12e19ba6d0b1f7baf5de900c98dfedd8622
3+
sha256=1b6e5d83d56a78754699f492c669ffae696349b4ad58e8f3225202dd0dadfb40
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
468cdc7e77405ca20d6adad73010322b84e33718
1+
07b01bf0103549b7b03c6b356e0aa797b82d5e37

src/sage/rings/integer.pyx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4963,6 +4963,12 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
49634963
(2, 2)
49644964
sage: 256.perfect_power()
49654965
(2, 8)
4966+
4967+
Test small powers of even numbers that are not a power of 2
4968+
(see :issue:`40846`)::
4969+
4970+
sage: (26**2).perfect_power()
4971+
(26, 2)
49664972
"""
49674973
cdef long n
49684974
# Fast PARI-free path
@@ -4974,7 +4980,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
49744980
if not (n & 1):
49754981
if mpz_popcount(self.value) == 1:
49764982
return smallInteger(2), smallInteger(mpz_sizeinbase(self.value, 2) - 1)
4977-
if n < 1000:
4983+
elif n < 1000:
49784984
if _small_primes_table[n >> 1]:
49794985
return self, one
49804986

0 commit comments

Comments
 (0)