Who are they?

Primus-Orderus Primes (POP) are primes which contain their order in the sequence of primes.
So the nth prime, in order to be POP, must contain all the digits of n in a certain way which I'll explain.


Let's get things clearer: All digits of n must appear among the digits of POP in the same order they appear in n

The 6469th prime is 64679 which is POP because it contains all digits of 6469 in the right order .
1407647 is POP because it is the 107647th prime number

14968819 is POP (968819th prime).So this challenge is NOT OEIS (A114924)

1327 is NOT POP because it is the 217th prime (digits are not in the right order)

The Challenge

You guessed right!
Given an integer n, output the nth POP

Test Cases

input-> output


This is so the shortest answer in bytes wins!

All these should be 1-Indexed

  • \$\begingroup\$ 0-indexed, 1-indexed or dealer's choice? \$\endgroup\$
    – Shaggy
    Aug 27, 2017 at 16:50
  • \$\begingroup\$ @Shaggy I think this is 1-indexed such that it is compatible with the test cases (The order kind of matters). \$\endgroup\$
    – Mr. Xcoder
    Aug 27, 2017 at 16:50
  • \$\begingroup\$ @Mr.Xcoder It is the 1st POP, 7th prime \$\endgroup\$
    – user73398
    Aug 27, 2017 at 16:56
  • \$\begingroup\$ @MrXcoder: yeah, sorry, I probably phrased that poorly; what I was meaning to ask is 0-indexing allowed? Obviously, from the test cases, 1-indexing is allowed. Do we have a consensus, by the way, on which indexing we can use in a challenge if all we have to go by is the test cases and there's no explicit mention in the challenge specs? \$\endgroup\$
    – Shaggy
    Aug 27, 2017 at 16:56
  • 1
    \$\begingroup\$ Thanks, Bill. While, for the most part, your recent challenges have been very good, each of them has had a minor issue or 2 that has had to be cleared up in the comments, which is why I'd suggest you start Sandboxing your challenges, to allow us to catch those issues. \$\endgroup\$
    – Shaggy
    Aug 27, 2017 at 16:59

5 Answers 5


Mathematica, 104 bytes

Extremely efficient


finds n=34 in under a minute


Husk, 11 bytes


Try it online!

Not that fast, computes f(5) in around 30 seconds on TIO


 f       İp    Filter the list of prime numbers and keep only those for which:
  S¤o€Ṗdṗ       The "d"igits of its index in the "ṗ"rime numbers are an "€"lement of the 
                  "Ṗ"owerset of its "d"igits
!              Return the element at the desired index of this filtered list

Python 2 + gmpy2, 188 162 bytes

Quite efficient, finds n=34 in 22 seconds on TIO!

Could probably be golfed a bit

from gmpy2 import*
def F(a,b):
 while b[i:]and a[k:]:k+=a[k]==b[i];i+=1
while x:z=next_prime(z);x-=F(`u`,`z`);u+=1
print z

Try it online!

  • \$\begingroup\$ @Dopapp, wouldn't that add bytes? __import__("gmpy2"). is longer than from gmpy2 import*\n \$\endgroup\$ Aug 27, 2017 at 20:23
  • \$\begingroup\$ Oh right I don’t know why that came out different the first time. I probably forgot the quotation marks or something \$\endgroup\$
    – Daniel
    Aug 27, 2017 at 20:25

05AB1E, 11 bytes


Try it online!

Extremely inefficient.


Jelly, 12 bytes


Try it online!

Extremely inefficient but works.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.