2016-04-01, post № 114

**mathematics**, #generating, #prime formula, #primes

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

The constant’s approximation.

The formula calculates the 𝑛-th prime.

The first few values for when starting with 𝑛 = 𝟢 are as follows.

2016-03-28, post № 113

**art**, #1 year, #1st, #animated, #animated gif, #birthday, #celebrate, #gif, #one year

J-Blog celebrates its first anniversary!

2016-03-27, post № 112

**art**, #animated, #animated gif, #bunny, #celebrating, #celebrating easter, #chicken, #egg, #gif, #present, #rabbit

Little pixel guy wishes you a happy easter!

2016-03-26, post № 111

**mathematics**, **programming**, **Pygame**, **Python**, #crown, #generate, #sequence

Pascal’s triangle is an interesting mathematical sequence. It is often written as a triangle, starting with , then . To generate the next row, you add the two numbers above to form another one. So the next row in the sequence is then , and so on (sequence A007318 in OEIS).

One interesting property of Pascal’s triangle is the generation of binomials.

To calculate , you can look at the 𝟦-th row (listed above and when starting to count at 𝟢) and determine

This program generates Pascal’s sequence in a rather unusual shape, looking a bit like a crown.

To get more information about Pascal’s triangle, check out this Wikipedia entry.

## Controls

- ‘F1’ advances the sequence,
- ‘Space’ takes a screenshot.

2016-03-23, post № 110

**mathematics**, **programming**, **Python**, #generating, #numbers, #palindrome, #palindromes, #palindromic numbers, #prime numbers, #prime palindromes, #symmetric numbers, #symmetry

TheOnlinePhotographer has published a post to celebrate 𝟣𝟩𝟣𝟩𝟣𝟩 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 𝟥, 𝟦𝟢𝟦 or 𝟣𝟩𝟤𝟤𝟩𝟣.

Lynn then went further and checked if 𝟣𝟩𝟣𝟩𝟣𝟩 is at least a prime. The number sadly has five distinct prime factors ().

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 𝟣𝟤𝟢 palindromic primes are shown below.

Based on this list, the smallest palindromic prime larger than 𝟣𝟩𝟣𝟩𝟣𝟩 is __𝟣𝟢𝟢𝟥𝟢𝟢𝟣__.

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 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).

2016-03-19, post № 109

**programming**, **Pygame**, **Python**, #16777216, #256**3, #all rgb, #blue, #colors, #every rgb color, #green, #red

Listing the red part on the 𝑥-axis, the green part on the 𝑦-axis and the blue part on the 𝑧-axis, this program displays all the 𝟣𝟨𝟩𝟩𝟩𝟤𝟣𝟨 colors rgb can display.

The 𝑧-axis is shown over time, visually going through a cube of colors.

2016-03-12, post № 108

**art**, #animated, #animated gif, #beach, #board, #flip, #gif, #ocean, #surf, #surf board, #wave

The little pixel guy tries himself at surfing.

2016-03-05, post № 107

**mathematics**, **programming**, **Python**, #approx., #approximating, #approximation, #John Conway, #lambda, #number sequence, #sequence

An interesting nonmathematical sequence which yet has interesting mathematical properties is the Look-and-say sequence.

As every good sequence it starts with a 𝟣. From there you get each next entry by looking at the previous and saying it. The next entry will thus be “one 𝟣” or 𝟣𝟣. From there “two 𝟣” or 𝟤𝟣, then “one 𝟤; one 𝟣” or 𝟣𝟤𝟣𝟣, “one 𝟣; one 𝟤; two 𝟣” or 𝟣𝟣𝟣𝟤𝟤𝟣 and so on.

## Generating the Sequence

The mathematical property, although, does not lie in the entry’s value, but rather in its length.

## Calculating the Length of each Entry

The interesting thing about the length is, that it approximately grows by 𝜆 each time.

This constant 𝜆 can be calculated by getting the real root of a degree 𝟩𝟣 polynomial (see Nathaniel Johnston’s post for further information) or be approximated by dividing entries.

## Approximating 𝜆

2016-02-27, post № 106

**mathematics**, **programming**, **Pygame**, **Python**, #animated gif, #automation, #black, #black and white, #carpet, #cell, #cell simulation, #cellular, #cellular automation, #cellular simulation, #fractal, #generating, #generation, #gif, #iterations, #weave, #white, #woven

The Haferman Carpet is a fractal, which kind of looks like a woven carpet. To generate it, you start with a single black pixel and apply in each cycle a set of rules.

In each generation every pixel in the carpet will be replaced by nine pixels according to the rules. A black pixel is represented by a 𝟢, a white one by a 𝟣.

## The Rules

2016-02-20, post № 105

**programming**, **Pygame**, **Python**, #angle, #around, #filter, #image, #image filter, #image manipulation, #manipulation, #spinning, #spun, #spun around, #stir, #vector

Using a vector and an angle, rotating each pixel’s position by an angle determined by its distance to the image’s center and a constant, this filter gives the image a unique spin.

For demonstration I used — once again — an image from my post Stacking Stones.

2016-02-13, post № 104

**games**, **mathematics**, **programming**, **Pygame**, **Python**, #cells, #cell, #cell simulation, #cellular, #cellular automation, #cellular game, #cellular simulation, #John Conway, #simulation

This program is a simulation of the famous cellular automaton created by John Conway. The so-called ‘game’ is rather a simulated evolution of cells in a two-dimensional world. Each cell can either be dead (black) or alive (white) and always has eight neighbours surrounding them. In each cycle of the simulation their state will be changed based on two simple rules, which are listed below.

Despite the rule’s simplicity, the outcomes are often very interesting and complex.

For more details on the game of life, check this Wikipedia entry.

## The Rules

- A live cell can only survive with exactly 𝟤 or 𝟥 neighbours, or else it dies.
- A dead cell with exactly 𝟥 neighbours comes to life.

## Controls

- Left click turns cell at current mouse position alive,
- Right click turns cell at current mouse position dead,
- ‘r’ turns every cell dead,
- ‘q’ cycles once,
- ‘w’ cycles continuously.

Posts:

235-225, 224-214, 213-203, 202-192, 191-181, 180-170, 169-159, 158-148, 147-137, 136-126, 125-115, **114-104**, 103-93, 92-82, 81-71, 70-60, 59-49, 48-38, 37-27, 26-16, 15-5, 4-1