It's Prime Time!

(code60, solved by 352)

Description: We all know that prime numbers are quite important in cryptography. Can you help me to find some?

Service: 188.166.133.53:11059

指定されたIPアドレス:ポートに接続すると、表示された数の次の素数を答える問題が次々と出題されます。Rubyプログラムに自動的に解かせます。

require "socket"
require "prime"

begin
  sock = TCPSocket.open("188.166.133.53", 11059)
rescue
  puts "TCPSocket.open failed : #$!\n"
else
    while sock.gets
      ary = ""
      buf = $_
      printf( buf )
      if buf.include?(".:") then
        ary = buf.split(" ")
        ary[8].delete!(":")
        ans = Prime.each.find {|e| e > ary[8].to_i}
        printf( ans.to_s )
        sock.write(ans.to_s + "\n")
        STDOUT.flush
      else
      end
    end
  sock.close
end

実行すると、次のとおり100問正解でフラグが表示されました。

Hi, you know that prime numbers are important, don't you? Help me calculating the next prime!
Level 1.: Find the next prime number after 7:
11

Yay, that's right!
(略)

Level 100.: Find the next prime number after 400:
401

Yay, that's right!
IW{Pr1m3s_4r3_!mp0rt4nt}

フラグは、

IW{Pr1m3s_4r3_!mp0rt4nt}

です。