Opened 10 years ago

Closed 10 years ago

# primes can have better functionality.

Reported by: Owned by: mderickx was major sage-4.7 number theory prime, iterator, beginner niles sage-4.7.alpha2 Douglas McNeil Karl-Dieter Crisman N/A

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
```

### 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 :)

### comment:5 Changed 10 years ago by kcrisman

• Description modified (diff)
• Reviewers set to Karl-Dieter Crisman
• Status changed from needs_review to positive_review

This is a great patch, nicely tested. I've made some minor tweaks in the documentation to remove some errors in the docbuild and a few other things like indentation, and added one doctest. Positive review.

### Changed 10 years ago by kcrisman

Apply after initial patch

### comment:6 Changed 10 years ago by kcrisman

• Description modified (diff)

### comment:7 Changed 10 years ago by jdemeyer

• Description modified (diff)

### comment:8 Changed 10 years ago by jdemeyer

• Merged in set to sage-4.7.alpha2
• Resolution set to fixed
• Status changed from positive_review to closed

### comment:9 Changed 10 years ago by jdemeyer

• Authors changed from D. S. McNeil to Douglas McNeil
Note: See TracTickets for help on using tickets.