top of page

Sophie Germain Primes

Sophie Germain was a French mathematician that lived from 1776 to 1831. Highly motivated, curious and mainly self-taught from the books in her father's library, she pursued the independent study of mathematics for the love of the subject. She lived during a time when the field of mathematics was dominated by men and therefore, she wrote papers under the pseudonym of M. Le Blanc to hide her gender.

She corresponded with several famous mathematicians of her time, including Lagrange, Legendre and the legendary Carl Friedrich Gauss. Eventually, mathematicians such as Gauss and Lagrange learned her true identity and praised her work on the topics of number theory and elasticity.

Let us look at one type of number named after her:

In number theory, a prime number p is a Sophie Germain prime if 2p + 1 is also prime.

For example, the number 5 is a Sophie Germain prime because 5 is prime and so is 11.

2(5) + 1 = 11

In Common Lisp, we can write a predicate, sophiep, that tests for this quality. (We assume we have another predicate primep that can test for primality.

(defun sophiep (n)
  "is n a Sophie Germain Prime?"
  (if (and (primep n) 
           (primep (+ (* 2 n) 1)))

Using the loop macro, we can easily generate a list of Sophie Germain primes between two values:

(loop for n from 1 to 100 
  when (sophiep n) collect n)
(2 3 5 11 23 29 41 53 83 89)

This simple example, shows the usefulness of Common Lisp as a free tool that can be used to learn and explore Discrete Mathematics without requiring proprietary math software.


Musielak, D. (2015). Prime mystery: The life and mathematics of Sophie Germain. AuthorHouse. 2022. Sophie Germain - Wikipedia. [online] Available at: <>

23 views0 comments

Recent Posts

See All

Getting Started

So you've heard of Lisp but how do you do Lisp? For being such a classic language that has been around for more than 60 years, sometimes it feels like there's a barrier to entry to get a full Lisp sys


Post: Blog2_Post
bottom of page