# Some fun with primes ... and Geogebra

Thursday 18 January 2018

Prime numbers are fascinating, mysterious and useful. The topic of prime numbers can pop up in a maths lesson at many different ages and ability levels. The announcement two weeks ago of a ‘new’ **largest known prime number** \(\left( {{2^{77,232,917}} - 1} \right)\) led to some interesting discussions in a couple of my classes the past couple of weeks. I have a poster in my classroom that lists all the prime numbers between 1 and 10,000 (there are 1229 of them) – and it gives some impression about the distribution of prime numbers. The 'density' of primes certainly seems to decrease as we move to ever larger positive integers. Students are intrigued by this. It might be an opportunity to mention the **Prime Number Theorem** (good *Numberphile *video here on it), but I think it might be a bit too much for most students. If time allows, I find it fun to give students some way to actively explore something about prime numbers, and how they are - or how they are not - distributed is very accessible given some easy-to-use maths software such as **Geogebra**.

The important thing to me is the * active *exploring - rather than just passively reading something about prime numbers on a website. So, the task that we set ourselves in one of my classes this week was to use Geogebra to produce some kind of

**frequency distribution plot**for all 1229 prime numbers between 1 and 10,000. When I can carve a bit of time out of a Maths HL or SL class (especially 1st year), I like doing activities with suitable maths software because it shows students what kind of tools that might be useful to them when they are writing their Exploration (IA). So, activities like this can act as a type of mini-tutorial on using some technology - Geogebra in this case.

__ Note__: I wrote a blog post three years ago this month about how a classroom discussion lead to some students writing a computer program - and me writing a program on the TI-Nspire - that counted the number of primes that occur for certain intervals. But using Geogebra is significantly easier and more accessible to students than writing a calculator or computer program.

We decided that we would try to display a plot on Geogebra that indicates the number of primes for each interval of 100 integers from 1 to 10,000. That is, how many primes between 1-100, 101-200, 201-300, etc. Here is what I did - with some support (mostly in the form of asking questions) from my students. I fully accept that someone with a higher level of expertise with Geogebra may come up with a more efficient way of producing the frequency distribution plot - but this works well, and does not take long. So, below I have attempted to clearly explain the 11 steps (along with some other tips) for producing the plot we wanted.

**Creating a frequency distribution plot of prime numbers with Geogebra**

This is a set of instructions for creating a list of prime numbers up to some maximum number (10,000 is used here), and then creating a plot that shows the number (frequency) of primes for each interval (interval width is 100 for this example). The maximum number and interval width can easily be changed to create different frequency plots. [__note__: I used Geogebra Classic v.6, but these instructions should be useful for other versions]

Start with *Algebra*, *Graphics* and *Spreadsheet* views open.

**1.** So that the dots in the plot are not too large (and possibly overlap), it’s a good idea to change the default size for points. Choose the **Point** tool and click on the point symbol (**Set point style**) in upper right of screen. I suggest setting the dot to solid format and size 3.

**2.** Use the **Sequence** command to create a list, **L _{1}**, of integers from 2 (first prime number) up to your chosen maximum number (again, using 10,000).

**L**

_{1}= Sequence(i, i, 2, 10**000)**

**3.** Use the **Sequence** and **IsPrime** commands to create a list, **L _{2}**, by testing whether each number in

**L**is prime or not. If a number in

_{1}**L**is prime then it is not changed, and if the number is not prime it is replaced with the number zero.

_{1}**L**

_{2}= Sequence(If(IsPrime(L_{1}(i))==true, L_{1}(i), 0) 1, 9**999)**

[__note__: enter this command very carefully because of all the brackets; the numbers in **L _{1}** go from 2 to 10000, so there are 9999 numbers in

**L**; write subscripts using underscore – e.g.

_{1}**L**is entered as L_1 ]

_{1}**4.** Use the **Unique** command to create a list, **L _{3}**, that removes all the repeated zeros in

**L**except one zero at the start of the list.

_{2}**L**

_{3}= Unique(L_{2})**5.** Use the **Remove** command to remove the zero at start of **L _{3},** creating

**L**.

_{4}**L**

_{4}= Remove(L_{3}, {0})**6.** Use the **Sequence** command to create a list, **L _{5}**, of the interval endpoints (upper & lower values).

**L**[

_{5}= Sequence(100i, i, 0, 100)__note__: the last number, 100, comes from finding how many times the chosen interval width (100 here) divides into the maximum number; e.g. 10 000/100 = 100]

**7.** Use the **Frequency** command (see below) to create a list, **L _{6}**, that counts the number of primes in each interval.

**L**

_{6}= Frequency(L_{5}, L_{4})**8.** For the points that will eventually be plotted, the 1^{st} coordinate is the upper value for each interval (100, 200, 300, etc) and the 2^{nd} coordinate is the number of primes (frequency) for that interval. Use the **Sequence** command to create a list, **L _{7}**, of the upper value for each interval.

**L**

_{7}= Sequence(100i, i, 1, 100)**9.** Use the **FillColumn** command (twice) to fill column B in the spreadsheet with upper value for each interval (**L _{7}**); and fill column C with the frequencies (

**L**).

_{6}**FillColumn(2, L**and

_{7})**FillColumn(3, L**

_{6})[__note__: In FillColumn command, the number refers to the column; 2=B, 3=C)

Before the final steps, it is a good idea to set suitable graph dimensions and formatting for the *Graphics* view. Clearly the *x*-axis should go from 0 to 10000, for the maximum number of 10000 in this example. The maximum frequency is 25 (1^{st} interval from 0 to 100), so the *y*-axis should go from 0 to around 30. I prefer to turn the grid off (no gridlines shown), or at least have some suitable grid settings – such as show only major gridlines and make the ‘distance’ 500 or 1000 for the *x*-axis (for this example with interval width of 100).

**10.** In *Spreadsheet* view, select columns B and C. Choose the {•••} **List of Points** tool. Two things should occur: (i) a plot of all the points appear in the Graphics view, and (ii) a new list, **L _{8}**, is created in the

*Algebra*view.

**L**contains all the ordered pairs, (

_{8}**L**), of the plotted points.

_{7}, L_{6}[__note__: A preview of **L _{8}** will appear in a box and you need to click on the Create button; it may take a few seconds before the plot of points appear in the

*Graphics*view)

**11**. Use the **FillColumn** command to fill column A with the ordered pairs of all the plotted points.** FillColumn(1, L _{8})** If you select an ordered pair from column A, the corresponding point is highlighted in the Graphics view. You can move quickly down the list of points in column A by just repeatedly pressing the down arrow and observe how the frequencies change (decrease) in the

*Graphics*view. Image of final plot below.

download PDF file of the **11-step set of instructions**

## Comments

To post comments you need to log in. If it is your first time you will need to subscribe.