# Formula for composite numbers

I was digging around blogspot when I came upon an old post that claimed the author discovered a formula that generates all odd composite numbers.

The post:

The formula:

$2x -1+4y(x+y)$ for all positive integer values of x and y.

It is my understanding that a formula for all composite numbers (that is every even number paired with formula above) subtracted by a given magnitude would be a prime counting function.

Denoting $q$ as a given magnitude $\frac{q}{2}$ $+(2x -1+4y(x+y))$ fitted for the magnitude $q$ $=\pi(x)$. (Please feel free to edit)

All I'm looking for is an explanation of this post as well as to how a formula for all composite numbers would correspond to a prime counting function. Thank you.

• It is $(2y+1)(2y+2x-1)$, more complicated than $(2x+1)(2y+1)$, or $(x+1)(y+1)$, which also takes care of even composites. I do not see any way of turning this into a prime-counting function. – André Nicolas Sep 10 '15 at 23:45

You can generate the composites with this Excel cell formula which uses no number theoretic functions at all:

=IF(COLUMN()=1,1,IF(ROW()=COLUMN(),ROW()-ROW()*PRODUCT(INDIRECT(ADDRESS(ROW(),1)
-COLUMN(),COLUMN())),"")))


but if you look at the cell formula and the table in the picture, you will find that it is only a sieve since every time one row contains a zero it will cause the diagonal entries to be equal to the row index, which happens at the composite numbers.

You can make it into the characteristic sequence of composite numbers by not multiplying with the row index:

=IF(COLUMN()=1,1,IF(ROW()=COLUMN(),1-PRODUCT(INDIRECT(ADDRESS(ROW(),1)
-COLUMN(),COLUMN())),"")))


But a recurrence for the prime counting function using these spreadsheet formulas I don't think is possible.

I propose the following formula of composite numbers, except divisible by 2 and 3: Positive integers contained in two 2-dimensional arrays:$P1(i,j)=6i^2-1+(6i-1)(j-1)$ and $P2(i,j)=6i^2-1+(6i+1)(j-1)$ are indexes $p$ of all composite numbers in the sequence $S1(p)=6p+5, p=0,1,2,...$ Positive integers contained in two 2-dimensional arrays: $P3(i,j)=6i^2-1-2i+(6i-1)(j-1)$ and $P4(i,j)=6i^2-1+2i+(6i+1)(j-1)$ are indexes $p$ of all composite numbers in the sequence $S2(p)=6p+7, p=0,1,2,...; i,j=1,2,3,...$

                                      |5     10     15     20 ..|
P1(i,j)=  |23    34     45     56...|
|53    70     87    104...|
|95   118    141    164...|
|149  178    207    236...|
|...  ...    ...     ...  |

| 5     12     19     26 ..|
|23     36     49     62...|
P2(i,j)=  |53     72     91    110...|
|95    120    145    170...|
|149   180    211    242...|
|...      ...      ...  ...|

|3        8     13     18 ..|
|19      30     41     52...|
|47      64     81     98...|
P3(i,j)= |87     110    133    156...|
|139    168    197    226...|
|...    ...    ...    ...   |

|7    14     21     28 ..|
|27   40     53     66...|
P4(i,j)= |59   78     97     116..|
|103  128   153    178...|
|159  190   221    252...|
|...  ...   ...     ...  |

• These formulae of arrays are general formulae of composite numbers in the sequences $S1(p)=6p+1 – Boris Sklyar Nov 12 '16 at 16:43 • and$S2(p)=6p+7$, and since all prime numbers belong to these sequences (except 2 and 3) so indexes of primes are that positive integers which do not appear in these arrays. – Boris Sklyar Nov 12 '16 at 16:59 • For example: Find positive integers <30, which do not appear in two arrays$P1(i,j)$and$P2(i,j)\$: | 5 10 15 20 25 30| |23 34 45 56 67 78| and |5 12 19 26 33 40| |23 36 49 62 75 88| The answer is obvious: 0, 1, 2, 3, 4, , 6, 7, 8, 9, , 11, , 13, 14, , 16, 17, 18, , , 21, 22, , 24, , , 27, 28, 29, , (These integers are indexes p of 20 first primes in the sequence S1=6p+5). – Boris Sklyar Nov 12 '16 at 17:11