## Prime Intirety

Since ancient times humanity knew that there are infinitely many primes — though countable, writing a complete list of every prime is impossible if one intends to finish.
However, in practice one often only considers a minute subset of the naturals to work with and think about. When writing low-level languages like C, one is nearly forced to forget about almost every natural number — the data type u_int_32, for example, is only capable of representing $\{\mathbb{N}_0\ni n<2^{32}\}$.
Therefore, it is possible to produce a complete list of every prime representable in thirty-two bits using standard bit pattern interpretation — the entirety of the first $203\,280\,221$ primes.

Generating said list took about two minutes on a 4GHz Intel Core i7 using an elementary sieve approach written in C compiled with gcc -O2.
All primes are stored in little-endian format and packed densely together, requiring four bytes each.

Using the resulting file, one can quickly index the primes, for example $p_{10^7} = 179\,424\,691 = \text{ab1cdb3}_{16}$ (using zero-based indexing). Since each prime is stored using four bytes, the prime’s index is scaled by a factor of four, resulting in its byte index.

dd status=none ibs=1 count=4 if=primes.bin skip=40000000 | xxd
00000000: b3cd b10a                                ....


Source code: intirety.c
Prime list: primes.bin (775.5 MiB)

## A285494

The On-Line Encyclopedia of Integer Sequences gets regularly updated with new integer sequences. One of the recent updates was contributed by me, A285494.

A285494 is the list of all numbers $k$ so that its digit sum equals its number of distinct prime factors.
A number’s digit sum is the sum of all of its decimal digits. The number $62831853$, for example, has a digit sum of $6+2+8+3+1+8+5+3 = 36$.
A number’s number of distinct prime factors is the number of different prime numbers that multiply together to result in the original number. As an example, $62831853 = 3^2 \cdot 7 \cdot 127 \cdot 7853$, so it has five prime factors of which four are distinct.
Thereby one can conclude that $62831853$ is not an entry in this sequence, as $36 \neq 4$.

The sequence is certainly infinite, as the number $k = 2 \cdot 10^n$ with $n \in \mathbb{N}^*$ has a digit sum of $2 + (0 \cdot n) = 2$ and — because $k = 2^{n+1} \cdot 5^n$ — exactly two distinct prime factors.

In the encyclopedia entry, I provided a Mathematica one-liner to compute the first few entries of this sequence. Since then, I have also written a Python two-liner to achieve the same goal.

(* Mathematica *)
Select[Range[2,10000],Total[IntegerDigits[#]]==Length[FactorInteger[#]]&]
Out = {20, 30, 102, 120, 200, 300, 1002, 1200, 2000, 2001, 2002, 3000, 3010}

# Python 2.7
>>> def p(n):exec"i,f=2,set()\nwhile n>1:\n\tif n%i==0:f.add(i);n/=i;i=1\n\ti+=1";return len(f)
>>> print filter(lambda n:p(n)==sum(map(int,str(n))),range(2,10001))
[20, 30, 102, 120, 200, 300, 1002, 1200, 2000, 2001, 2002, 3000, 3010]


## TI-99/4A Primes

Being a fan of old hardware, I used the TI-99/4A (released in 1981) to calculate some primes.
The code is written in BASIC, the programming language found on most computers of this era.
Further information on the TI can be found in this Wikipedia article.

1   REM TI-99/4A BASIC Code
2   REM Jonathan Frech 20th of May, 2016