require 'prime' prime_list = [] (2..10000).each do |i| if i.prime? prime_list << i end end #p prime_list game = {2 => "Lose"} n = gets.strip.to_i (3..n).each do |i| match = "Lose" (0...prime_list.length).each do |j| if prime_list[j] >= n break end if i - prime_list[j] == 0 || i - prime_list[j] == 1 next end if game[i - prime_list[j]] == "Lose" match = "Win" break end end game[i] = match end puts game[n]