#!/usr/bin/env ruby
# -*- coding:utf-8 -*-
require 'io/console/size'
print("\e[2J") #画面を全部消して
print("\e[%d;%dH" % IO::console_size.map{|size| size / 2 }) #画面の真ん中に行く
z=0
a=0.5
ugoku=["C","A","B","D"]
prime=[]
while z<IO::console_size[0]*IO::console_size[1]
  printf("\e[1%s",ugoku[z%4])
  if z==1
    next
  elsif z==2
    prime<<z
    print("@")
    print("\e[1D")
    next
    sleep(0.5)
  end
  b=0
  while b<a.ceil
    judge=true
    prime.each do |i|
      next if i==0
      if z%i==0
        judge=false
        break
      end
    end
    if judge
      prime<<z
      print("@")
      print("\e[1D")
      sleep(0.5)
    end
    b+=1
  end
  a+=0.5
  z+=1
end
