For a problem on a sample space of cardinality up to 1229, it is possible to encode the information inside a 4-byte integer.
We can do it with prime number multiplication - the product is uniquely decomposable as everybody knows. The product of the first 1229 prime numbers fits within MAXINT!!!
The possibilities are endless....
- sonofdelphi
Absurd numerological coincidence :) * Discovery made on 6/29. If 12/29 is divided by 6/29, the result is 2/1 !!!
Logical end of
Bus-Routes
Looking for a function
Code used to make the discovery Hardly optimal. Stolen from the web and modified.
1 comment:
Just made a discovery!
For a problem on a sample space of cardinality up to 1229, it is possible to encode the information inside a 4-byte integer.
We can do it with prime number multiplication - the product is uniquely decomposable as everybody knows. The product of the first 1229 prime numbers fits within MAXINT!!!
The possibilities are endless....
- sonofdelphi
Absurd numerological coincidence :)
* Discovery made on 6/29. If 12/29 is divided by 6/29, the result is 2/1 !!!
Logical end of
Bus-Routes
Looking for a function
Code used to make the discovery
Hardly optimal. Stolen from the web and modified.
#include stdio.h
#include iostream
#include vector
using namespace std;
vector int anPrimes;
#define LIMIT 10000
void main()
{
int n=LIMIT,i=1,j,c;
unsigned int nProduct=1;
unsigned int nPrimeCount=0;
unsigned int nLastPrime = 0;
unsigned int nLastProduct = 0;
while(i<=n)
{
c=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
c++;
}
if(c==2)
{
nProduct *= i;
if(nProduct > UINT_MAX)
break;
nPrimeCount++;
nLastPrime = i;
nLastProduct = nProduct;
}
i++;
}
cout "Last Prime : " nLastPrime endl;
cout "Prime Cardinal: " nPrimeCount endl;
cout "Product : " nProduct endl;
cout "MAXINT : " UINT_MAX endl;
getchar();
}
OUTPUT
Last Prime : 9973
Prime Cardinal: 1229
Product : 3975369062
MAXINT : 4294967295
Post a Comment