On Fri, Sep 21, 2012 at 7:53 AM, kcrisman <kcris...@gmail.com> wrote:
>
>
> On Friday, September 21, 2012 9:14:54 AM UTC-4, Peter Mueller wrote:
>>
>> 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
>>
>
> Apparently this hasn't been changed for a long time.  "hg blame" leads me to
>
>  7046:         start, stop = 1, integer.Integer(start)
> 10906:     v = fast_arith.prime_range(stop)
>  7046:         w.insert(0, integer.Integer(1))
>
> where 7046 is http://trac.sagemath.org/sage_trac/ticket/922 which doesn't
> cover this, and 10906 is from a generic cleanup ticket in 2008.
>
> Everything else from this changeset long long ago:
>
> 2329103:changeset:   5265:d6107e5bc8b1
> 2329134-user:        William Stein <wst...@gmail.com>
> 2329180-date:        Mon Jul 02 03:21:30 2007 -0700
> 2329224-summary:     Add prime_powers function.
>
> So I'm amazed that you are the first person to come across this!

A guess why:  I (and most people) never used this function except in
the form prime_powers(B), to compute all prime powers up to B.  That's
probably why this wasn't noticed before.  In applications, it is much
more common to want all prime powers up to a bound, instead of the
prime powers in an interval.

>
>>
>> PS: I submitted that yesterday via the `Report a Problem' link. Not sure
>> if that arrived.
>
>
> That spreadsheet is unfortunately not canvassed as often as we'd like, so
> it's great that you reported this here.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To post to this group, send email to sage-support@googlegroups.com.
> To unsubscribe from this group, send email to
> sage-support+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support?hl=en.
>
>



-- 
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.


Reply via email to