Opened 9 years ago

Last modified 9 years ago

#13516 closed defect

prime_powers doesn't work with start very well — at Version 3

Reported by: kcrisman Owned by: was
Priority: major Milestone: sage-5.6
Component: number theory Keywords: beginner
Cc: was Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by khalasz)

See this sage-support thread.

In Sage 5.3, the function prime_powers behaves a little strange:

sage: prime_powers(4,10)
[4, 5, 7, 8, 9]
# As expected

sage: prime_powers(5,10)
[7, 8, 9]
# 5 isn't a prime power anymore???

# And now things become even worse:
sage: prime_powers(7,10)
IndexError                                Traceback (most recent call last)

/home/mueller/<ipython console> in <module>()

/home/mueller/local/sage-5.3/local/lib/python2.7/site-packages/sage/rings/arith.pyc in prime_powers(start, stop)
    743     i = bisect(v, start)
    744     if start > 2:
--> 745         if v[i] == start:
    746             i -= 1
    747         w = list(v[i:])

IndexError: list index out of range

Yeah, this seems problematic. The code in question is old, too, so perhaps there is a more efficient way to do it in the meantime...


  1. 13516_primepowers.patch

Change History (3)

comment:1 Changed 9 years ago by kcrisman

  • Keywords beginner added

comment:2 Changed 9 years ago by dimpase

as prime_powers(m) works, an easy workaround is to re-implement prime_powers(m,n) as the difference of prime_powers(n) and prime_powers(m-1).

comment:3 Changed 9 years ago by khalasz

  • Description modified (diff)
  • Status changed from new to needs_review
Note: See TracTickets for help on using tickets.