I've been working on some stuff about prime quadruplets. For reasons too dull to explain just now I started by looking for a formula that always generates composite numbers. At some point when I get the chance I'll explain this a bit more, but after a bit of thought I came up with this:
2x -1+4y(x+y) for all positive integer values of x and y.
It does work, which is nice - it generates all the odd composites (which is all you need since all evens are composite except 2.
More later.
Edit: Obviously a formula like xy where x and y are positive integers > 1 is a great deal simpler, but for various reasons I wanted one for which you didn't need to exclude 1.
I propose the following formula of composite numbers, except divisible by 2 and 3:
ReplyDeletePositive 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,...
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=13752&lngWId=3
Boris Sklyar, brs.sklr@mail.ru
If formula for composite numbers
ReplyDelete4*i*i-1+2*j*(2*i+1)
is correct and include ALL composite numbers 9, 15, 21, 25, 27, 33, 35,...
than algorithm for finding prime numbers will be as follows.
Positive integers not contained in 2-dimensional array
4i^2-1+2j(2i+1)
(except divisible by 2) are all prime numbers.
And C++ program can be:
#include
#include
#include
using namespace std;
main( )
{
int i, j, j1,j2, K, k;
int i2=180;j2=190; k=140000;int q=2*k+1;
int R[q];
for (k=1;k<1100;k++)
{ int q=2*k+1;
R[q]=q;}
cout<<" \n";
for (i=1; i<i2;i++)
{for (j=1; j<j2;j++)
{K=4*i*i-1+2*j*(2*i+1);
R[K]=0;
}}
for (k=1;k<500;k++)
{q=2*k+1;
if (R[q]%5==0) continue;
cout<<" "<<R[q]<<" ";}
system("PAUSE");
return EXIT_SUCCESS;
}
#include
ReplyDelete#include
#include
using namespace std;
main( )
{
int i, j, j1,j2, K, k;
int i2=180;j2=190; k=140000;int q=2*k+1;
int R[q];
for (k=1;k<1100;k++)
{ int q=2*k+1;
R[q]=q;}
cout<<" \n";
for (i=1; i<i2;i++)
{for (j=1; j<j2;j++)
{K=4*i*i-1+2*j*(2*i+1);
R[K]=0;
}}
for (k=1;k<500;k++)
{q=2*k+1;
if (R[q]%5==0) continue;
cout<<" "<<R[q]<<" ";}
system("PAUSE");
return EXIT_SUCCESS;
}
This comment has been removed by the author.
ReplyDelete