## 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]


## Praiku

While you have no primes,
While you would like to know them.
If, if you could print…

_ = 1
while 1: # you have no primes
_, __, ___ = _ + 1, 1, 2
while ___ < _: # you would like to know them
if _ % ___ == 0: __ = 0
___ += 1
if __: "you could"; print _

## 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

## Factorization

Playing around with prime numbers, I created this simple factorization program.
The interesting thing about prime factors is that they are unique. There can only be one way to multiply prime numbers to get $n$ where $n \in \mathbb{N}$ and $n \geq 2$ (excluding the commutative property).
For example, $2 \cdot 3 \cdot 7 = 42$ and that is the only way to multiply prime numbers to get to $42$.

# Python 2.7.7 Code
# Jonathan Frech 8th of April, 2016

## Prime-Generating Formula

(April Fools’!) I came up with this interesting prime-generating formula. It uses the constant $\xi$ and generates the primes in order!

The constant’s approximation.
$\xi = 1.603502629914017832315523632362646507807932231768273436867961017532625344 \dots$

The formula $p_n$ calculates the n-th prime.
$p_n = \lfloor {10^{2 \cdot n} \cdot \sqrt{\xi^3}} \rfloor - \lfloor {10^{2 \cdot (n - 1)} \cdot \sqrt{\xi^3}} \rfloor \cdot 10^2$

The first few values for $p_n$ when starting with $n=0$ are as follows.
$p_{0 \text{ to } 7} = \{2, 3, 5, 7, 11, 13, 17, 19, \dots \}$

## Palindromic Primes

TheOnlinePhotographer has published a post to celebrate 171717 comments and was amused by the number’s symmetry.
A great comment by Lynn pointed out that this number is indeed an interesting number but not symmetrical.
Symmetrical numbers or words also called palindromes are defined as being the same read forwards or backwards. Examples for palindromic words are radar, noon or level. Palindromic numbers are 3, 404 or 172271.

Lynn then went further and checked if 171717 is at least a prime. The number sadly has five distinct prime factors $(171717 = 3 \cdot 7 \cdot 13 \cdot 17 \cdot 37)$.

So Lynn wondered what the next palindromic prime would be.
To answer this question, I wrote this little Python program to check for palindromic primes. The first 120 palindromic primes are shown below.
Based on this list, the smallest palindromic prime larger than 171717 is 1003001.

      3,       5,       7,      11,     101,     131,     151,     181,
191,     313,     353,     373,     383,     727,     757,     787,
797,     919,     929,   10301,   10501,   10601,   11311,   11411,
12421,   12721,   12821,   13331,   13831,   13931,   14341,   14741,
15451,   15551,   16061,   16361,   16561,   16661,   17471,   17971,
18181,   18481,   19391,   19891,   19991,   30103,   30203,   30403,
30703,   30803,   31013,   31513,   32323,   32423,   33533,   34543,
34843,   35053,   35153,   35353,   35753,   36263,   36563,   37273,
37573,   38083,   38183,   38783,   39293,   70207,   70507,   70607,
71317,   71917,   72227,   72727,   73037,   73237,   73637,   74047,
74747,   75557,   76367,   76667,   77377,   77477,   77977,   78487,
78787,   78887,   79397,   79697,   79997,   90709,   91019,   93139,
93239,   93739,   94049,   94349,   94649,   94849,   94949,   95959,
96269,   96469,   96769,   97379,   97579,   97879,   98389,   98689,
1003001, 1008001, 1022201, 1028201, 1035301, 1043401, 1055501, 1062601, ...

Thus it takes $1003001 - 171717 = 831284$ more comments to reach the closest palindromic prime.

The sequence of palindromic primes is number A002385 in the On-line Encyclopedia of Integer Sequences (OEIS).

# Python 2.7.7 Code
# Jonathan Frech 23rd of March, 2016

## Prime Circle

Using circles to visualize prime appearance. The picture below is 1080 x 720 pixels, thus showing numbers up to 540 (on the far left and right).

# Python 2.7.7 Code
# Pygame 1.9.1 (for Python 2.7.7)
# Jonathan Frech 26th of December, 2015

## JClock VII

This alternative clock is not really readable by human. It calculates the first 144¹ primes, assigns 60 of them to every possible second, 60 to every possible minute and 24 to every possible hour.
Multiplying those three primes for a given time results in a composite number representing said time. Using integer factorization, you then can get the three primes back, map them to seconds, minutes and hours, and by doing so calculate the time.

¹This number is the sum of 60 seconds, 60 minutes and 24 hours.

# Python 2.7.7 Code
# Pygame 1.9.1 (for Python 2.7.7)
# Jonathan Frech 13th of November, 2015

## Prime Remainders

This program calculates primes, takes their remainder¹ and then places a color accordingly. The shapes are quiet interesting.

#### Controls

• Space takes a screenshot

¹The formular for the color c at prime p with modulo m is c = p mod m. (m = 10 on the left, 255 on the right and 500 on the bottom)

# Python 2.7.7 Code
# Pygame 1.9.1 (for Python 2.7.7)
# Jonathan Frech 4th of November, 2015
#         edited 5th of November, 2015
#         edited 6th of November, 2015

## Primes II

Inspired by my Cixel filter, I designed another prime visualisation program.

# Python 2.7.7 Code
# Pygame 1.9.1 (for Python 2.7.7)
# Jonathan Frech 22nd of August   , 2015
#         edited 11th of September, 2015