fork(10) download
  1. import sys
  2. sys.setrecursionlimit(10000)
  3.  
  4. f=lambda n,k=2,m=1,s='':-~s.find(`n`)or f(n,k+1,m*k*k,s+m%k*`k`)
  5.  
  6. for n in 13, 997, 999, 314:
  7. print '%3u -> %4u' % (n, f(n))
Success #stdin #stdout 0.11s 9648KB
stdin
Standard input is empty
stdout
 13 ->    7
997 ->   44
999 -> 1013
314 ->  219