Opened 10 years ago

Last modified 10 years ago

#10784 closed enhancement

primes can have better functionality. — at Version 4

Reported by: mderickx Owned by: was
Priority: major Milestone: sage-4.7
Component: number theory Keywords: prime, iterator, beginner
Cc: niles Merged in:
Authors: D. S. McNeil Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by niles)

In this topic:

D.S. McNeil posted several ideas for enhancing sage. This ticket is for the enhancements proposed for the primes function.

(3) primes(10, infinity) should work. 
Since we're just calling next_prime, there's no reason to require the 
upper limit to be an integer. 
Wouldn't mind a proof=False option which calls next_probable_prime 
instead, either. 

Change History (5)

comment:1 Changed 10 years ago by mderickx

  • Component changed from PLEASE CHANGE to number theory
  • Milestone set to sage-4.7
  • Owner changed from tbd to was
  • Type changed from PLEASE CHANGE to enhancement

Changed 10 years ago by dsm

allow +infinity, proof

comment:2 Changed 10 years ago by dsm

Patch attached to allow support for infinity as upper bound and proof option (with same semantics as next_prime's proof option: it's simply passed through to next_prime).

First idea was to avoid casting to ZZ entirely, which would allow primes(2, 100/3), but that can lead to some mysterious error messages. Current approach simply special-cases infinity as an upper bound -- allowing -infinity as a lower bound isn't that useful, because unlike the case of an infinite upper bound, that can be easily worked around from outside the function, and so problems with the bounds are caught at first iteration, which seems better.

comment:3 Changed 10 years ago by dsm

  • Summary changed from primes can have better functionallity. to primes can have better functionality.

comment:4 Changed 10 years ago by niles

  • Authors set to D. S. McNeil
  • Cc niles added
  • Description modified (diff)
  • Keywords prime iterator beginner added
  • Status changed from new to needs_review

Looks really good -- I've marked it as 'beginner', meaning that this is a patch which someone who is just beginning could review. If no one beats me to it, I'll go ahead and review it :)

Note: See TracTickets for help on using tickets.