*a=0,1,1,2,4 5.upto(1e6){|i|a[i]=(a[-1]*2-a[-5])%17} gets $<.map{|n|p a[n.to_i-3]}