describe Integer, "#centered_n_gonal?" do
  @seq = {
    # A005448 
    3 =>  [1,4,10,19,31,46,64,85,109,136,166,199,235,274,
           316,361,409,460,514,571,631,694,760,829,901,976,
           1054,1135,1219,1306,1396,1489,1585,1684,1786,1891,
           1999,2110,2224,2341,2461,2584,2710,2839,2971,3106,
           3244,3385,3529],
    # A001844      
    4 =>  [1,5,13,25,41,61,85,113,145,181,221,265,313,365,
           421,481,545,613,685,761,841,925,1013,1105,1201,
           1301,1405,1513,1625,1741,1861,1985,2113,2245,2381,
           2521,2665,2813,2965,3121,3281,3445,3613,3785,3961,
           4141,4325],
    # A005891)      
    5 =>  [1,6,16,31,51,76,106,141,181,226,276,331,391,456,
           526,601,681,766,856,951,1051,1156,1266,1381,1501,
           1626,1756,1891,2031,2176,2326,2481,2641,2806,2976,
           3151,3331,3516,3706,3901,4101,4306,4516,4731,4951,
           5176,5406],
    # A003215      
    6 =>  [1,7,19,37,61,91,127,169,217,271,331,397,469,547,
           631,721,817,919,1027,1141,1261,1387,1519,1657,
           1801,1951,2107,2269,2437,2611,2791,2977,3169,3367,
           3571,3781,3997,4219,4447,4681,4921,5167,5419,5677,
           5941,6211,6487],
    # A069099
    7 =>  [1,8,22,43,71,106,148,197,253,316,386,463,547,638,
           736,841,953,1072,1198,1331,1471,1618,1772,1933,
           2101,2276,2458,2647,2843,3046,3256,3473,3697,3928,
           4166,4411,4663,4922,5188,5461,5741,6028,6322,6623,
           6931,7246],
    # A016754      
    8 =>  [1,9,25,49,81,121,169,225,289,361,441,529,625,729,
           841,961,1089,1225,1369,1521,1681,1849,2025,2209,
           2401,2601,2809,3025,3249,3481,3721,3969,4225,4489,
           4761,5041,5329,5625,5929,6241,6561,6889,7225,
           7569],
    # A060544 
    9 =>  [1,10,28,55,91,136,190,253,325,406,496,595,703,
           820,946,1081,1225,1378,1540,1711,1891,2080,2278,
           2485,2701,2926,3160,3403,3655,3916,4186,4465,4753,
           5050,5356,5671,5995,6328,6670,7021,7381,7750,8128,
           8515,8911,9316],
    # A062786
    10 => [1,11,31,61,101,151,211,281,361,451,551,661,781,
           911,1051,1201,1361,1531,1711,1901,2101,2311,2531,
           2761,3001,3251,3511,3781,4061,4351,4651,4961,5281,
           5611,5951,6301,6661,7031,7411,7801,8201,8611,9031,
           9461,9901]
  }

  @seq.each do |k, members|
    members.each do |n|
      it "should return true for centered #{k}-gonal number #{n}" do
        n.centered_n_gonal?(k).should be_true
      end
    end

    members.to_seq.invert.sample(10).each do |n|
      it "should return false for non-centered-#{k}-gonal number #{n}" do
        n.centered_n_gonal?(k).should be_false
      end
    end
  end
end
