Random Primes

Description

The command random_prime(a) generates a random prime between 2 and $a$. The command random_prime(a, proof=True) will generate a random prime number between 2 and $a$. Replacing proof=True by proof=False will speed up the search, but there will be a very, very, very small probability the result will not be prime. The default is proof=True, but this should be checked by executing

from sage.structure.proof.proof import get_flag
get_flag()

Sage Cell

Options

a = random_prime(10^21, proof=True)
a

Tags

Primary Tags: number theory

Secondary Tags: primes

Related Cells

Attribute

Permalink: http://abstract.ups.edu/aata/integers-sage.html

Author: R. Beezer

Date: 15 Jul 2017 08:32

Submitted by: Tom Judson

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License