Skip to main content
3 of 9
edited body
Dennis
  • 210.6k
  • 41
  • 370
  • 825

Python 2, 67 65 bytes

f=lambda n,k=0,m=2,p=1:k/n*~-m or f(n,k+p%m*(`n`in`m`),m+1,p*m*m)

Test it on Ideone.

Dennis
  • 210.6k
  • 41
  • 370
  • 825