Skip to content

Instantly share code, notes, and snippets.

@cmezak
Created January 14, 2014 23:22
Show Gist options
  • Save cmezak/8427944 to your computer and use it in GitHub Desktop.
Save cmezak/8427944 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
puts(lambda{|q|until(!(c||=Hash.new{|e,o|e[o]=[o<((q<=3) ? 2*q :
((q)*(p||=Proc.new{|l|Math.log(l)})[q]+q*p[p[q]])),true]})[(t||=2)][0])do
while((c[s||=(t**2)][1]=false)!=c[(s+=t)-t][0])do{}end unless(!c[t][1])
t,s=t+1;end;c.select{|w,j|j[1]}.keys.first(q)}[ARGV.last.to_i])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment