##Python 2, 127 bytes##
Python 2, 127 bytes
N=input();a,b=0,1
while N:a,b=b,a+b;t=int(''.join(c for c in hex(b)if ord(c)<65));N-=(t>1)*all(t%x for x in range(2,t))
print b
The algorithm could be a lot more efficient. In particular, the primality check (t>1)*all(t%x for x in range(2,t))
checks potential factors all the way up to t-1
, when really it would only have to check up to the floor of the square root. Since range
stores an entire list in memory in Python 2 , this leads to a MemoryError
at N=17
(on my machine using default settings).