RE: RE: Brainsteem: A Prime STEEMIT Number Puzzle
You are viewing a single comment's thread from:

RE: Brainsteem: A Prime STEEMIT Number Puzzle

Words
81
Reading
1 min
Listen
Play
7y

I know, I'm 2 years late, but still I decided to join the fun.

I like programming challenges, so I decided to go for the second tsk of finding all of them.
Here is my (java) code:

        for(int S = 1; S < 10; S++) {
            for(int T = 1; T < 10; T += 2) {
                if(S == 5)
                    continue;
                if(T == S)
                    continue;
                for(int E = 0; E < 10; E++) {
                    if(E == S || E == T)
                        continue;
                    for(int M = 0; M < 10; M++) {
                        if(M == S || M == T || M == E)
                            continue;
                        for(int I = 0; I < 10; I++) {
                            if(I == S || I == T || I == E || I == M)
                                continue;
                            int number = T+10*I+100*M+1000*E+10000*E+100000*T+1000000*S;
                            int maxFac = (int)Math.sqrt(number);
                            boolean is = true;
                            for(int i = 3; i < maxFac; i+=2) {
                                if(number % i == 0) {
                                    is = false;
                                    break;
                                }
                            }
                            if(is) {
                                System.out.println(number);
                            }
                        }
                    }
                }
            }
        }

The list of primes following that structure is too long(1540) to show here, but I can confirm that the lowest prime is in fact 1300253, followed by
1300283, 1300423, 1300463, 1300573, 1300583, 1300843, 1300963, …
…, 9788057, 9788137, 9788347, 9788357, 9788417, 9788437, 9788567, 9788657

@quantumdeveloper: I know, I'm 2 | Ecency