It implements prime number envelopes (page 3) from my paper: https://zenodo.org/records/16829092
The full working example is on github: https://github.com/cerebrummi/primeenvelopes
- "StartFA" has a main method that shows the sieve that grows prime numbers SFA with FA. [This part is equal to this question https://codereview.stackexchange.com/questions/297904] From my research implementation the pattern develop like this: https://www.youtube.com/watch?v=I0w78ewvum4
Step 2 and 3 are NEW!!!
"StartTree" has a main method that shows how a data structure (tree of leafs with floors) is being build in TFA from SFA with FA.
"StartEnvelopes" has a main method that uses the TFA to generate the prime number envelopes.
CODE
package common;
public class StartFA
{
final static int NUMBER_OF_STEPS = 8;
public static void main(String[] args)
{
SFA sfa = new SFA();
sfa.printWalksets();
for( int i = 0 ; i < NUMBER_OF_STEPS; i++)
{
System.out.println("========== step start ==========");
sfa.step();
sfa.printWalksets();
System.out.println("========== step end ===========");
}
}
}
AND
package common;
public class StartTree
{
final static int NUMBER_OF_STEPS = 12;
public static void main(String[] args)
{
TFA tfa = new TFA();
for (int i = 1; i < NUMBER_OF_STEPS; i++)
{
tfa.step();
}
// tfa.printFloors();
/**
* for NUMBER_OF_STEPS = 17
*
* TFA: patternsize 1
* TFA: patternsize 2
* TFA: patternsize 6
* TFA: patternsize 30
* TFA: patternsize 210
* TFA: patternsize 2310
* TFA: patternsize 30030
* TFA: patternsize 510510
*/
tfa.printPatternSizes();
}
}
AND
package common;
import java.math.BigDecimal;
import io.PrimeReader;
import tree.Floor;
public class StartEnvelopes
{
final static int NUMBER_OF_STEPS = 14;
public static void main(String[] args)
{
PrimeReader reader = new PrimeReader();
String primenumber = reader.readFromData();
//String primenumber = "19387777";
BigDecimal prime = new BigDecimal(primenumber);
TFA tfa = new TFA();
for (int i = 1; i < NUMBER_OF_STEPS; i++)
{
tfa.step();
}
Floor floor = tfa.getLastFloor();
do
{
int patternSize = floor.getPatternSize();
BigDecimal size = new BigDecimal(patternSize);
if (size.compareTo(prime) == 1)
{
floor = floor.getPreviousFloor();
}
else
{
break;
}
} while (floor != null);
System.out.println("StartEnvelope: prime number = " + primenumber);
System.out
.println("StartEnvelope: pattern size = " + floor.getPatternSize());
System.out.println("");
do
{
int a = floor.getPatternSize();
int b = floor.getLeaf(prime).intValue();
System.out.println("Envelope equation f(x) = " + a + "*x + " + b);
floor = floor.getPreviousFloor();
} while (floor != null);
}
}
