RE: RE: Brainsteem Compute #3 Prize Computational Maths Puzzle [Win 40% and 10% in SBD]
You are viewing a single comment's thread from:

RE: Brainsteem Compute #3 Prize Computational Maths Puzzle [Win 40% and 10% in SBD]

Words
40
Reading
1 min
Listen
Play
7y

That was fun!

The result should be:
8939662423123592347173339993799
Due to using some java-intern prime check my confidence is only
1-0.5²¹⁴⁷⁴⁸³⁶⁴⁷(I hate how the unicode superscript characters appear on different heights.)
And here is my (java) code:

    static BigInteger TEN = new BigInteger("10");
    static BigInteger MAX = new BigInteger("3");
    static BigInteger [] digits = new BigInteger[10];
    public static void main(String[] args) {
        for(int i = 0; i < 10; i++) {
            digits[i] = new BigInteger(i+"");
        }
        for(int i = 3; i < 10; i += 2) {
            makeChain(new BigInteger(i+""), 1);
        }
    }
    public static void makeChain(BigInteger start, int depth) {
        if(start.isProbablePrime(Integer.MAX_VALUE)) {
            if(start.compareTo(MAX) == 1) {
                MAX = start;
                System.out.println(MAX);
            }
        }
        else
            return;
        for(int i = 1; i < 10; i += 2) {
            if(i == 5)
                continue;
            makeChain(appendRight(start, i), depth+1);
        }
        for(int i = 1; i < 10; i++) {
            makeChain(appendLeft(start, i, depth), depth+1);
        }
    }
    public static BigInteger appendRight(BigInteger bi, int digit) {
        return bi.multiply(TEN).add(digits[digit]);
    }
    public static BigInteger appendLeft(BigInteger bi, int digit, int depth) {
        return bi.add(TEN.pow(depth).multiply(digits[digit]));
    }

Well, it's basically just brute-force.

@quantumdeveloper: That was fun! | Ecency