---
layout: post
title: Primes
---

## The Primes

Generate a listing of the first 14 primes.

{% highlight mathematica %}
seq1 = Table[Prime[x], {x, 14}]
{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43}
{% endhighlight %}

How about the consecutive pairs products?

{% highlight mathematica %}
seq2 = Table[Prime[x] Prime[x + 1], {x, 14}]
{6, 15, 35, 77, 143, 221, 323, 437, 667, 899, 1147, 1517, 1763, 2021}
{% endhighlight %}

How about listing the twin primes?

{% highlight mathematica %}
twinPs[n_] = If[(Prime[n + 1] - Prime[n]) == 2, {Prime[n], Prime[n + 1]}, 0]
alst = Table[twinPs[x], {x, 41}]
{% endhighlight %}

Sum of each pair of twin prime values?

{% highlight mathematica %}
Total[alst, {2}]
{0, 8, 12, 0, 24, 0, 36, 0, 0, 60, 0, 0, 84, 0, 0, 0, 120, 0, 0, 144, \
0, 0, 0, 0, 0, 204, 0, 216, 0, 0, 0, 0, 276, 0, 300, 0, 0, 0, 0, 0, 360}
{% endhighlight %}

Add new post; twin primes BothN
Add new post; twin primes BothN
