Chapter4Prime Time

Now it's time to introduce maybe the most important concept in the whole course - one you are already pretty familiar with. That is the concept of prime numbers.

Definition4.0.1
A positive integer \(p\) greater than 1 is called prime if the only positive divisors of \(p\) are \(1\) and \(p\) itself.
Definition4.0.2
If an integer \(n>1\) is not prime, it is called composite.

As you know, the first few primes are \(2,3,5,7,11,\ldots\) That means \(4,6,8,9,10,12\ldots\) are composite. But figuring out which numbers are prime is notoriously difficult (indeed, we will spend significant time later on this question.) So below, we introduce a few Sage functions for this.

Remark4.0.3

Sage note:
As is typical in Python, comments on them are given after # signs.

Here are answers to questions you might have about primes that Sage could answer.

  • Is a given number prime?
  • Is it at least a power of a prime?
  • List some primes for me!
  • List the first \(n\) primes...
  • Give me prime factors.
Remark4.0.4

Sage note:
You can put any legitimate Sage command in the cells above. (Try integrate(x^3,x) if you know some calculus.) Or you use these commands in your own Sage worksheet at your local Sage server, so that you can save your work!