2016年7月20日水曜日

160720(3)

Ruby


A Somos-4 like sequence connected with the elliptic curve y^2 + y = x^3 - 3x + 4(1)

オンライン整数列大辞典の
A259419(http://oeis.org/A259419/list)
と比較し、答え合わせしてみる。

def A259419(n)
  a = [1, 2, 1, -3]
  i = 3
  while i < n
    i += 1
    if i % 3 == 2
      a << (a[i - 1] * a[i - 3] - 3 * a[i - 2] * a[i - 2]) / a[i - 4]
    else
      a << (a[i - 1] * a[i - 3] -     a[i - 2] * a[i - 2]) / a[i - 4]
    end
  end
  a[0..n]
end
ary = A259419(26)

# OEIS A259419のデータ
ary0 =
[1,2,1,-3,-7,-17,2,101,247,571,-1669,-13766,
 -43101,-205897,1640929,8217293,101727662,
 173114917,-5439590147,-70987557871,-993401657957,
 2105332714614,208894282701569,3110590234593151,
 37334338699443371,-891470356091782993,
 -33292234868859857114]
# 一致の確認
p ary == ary0

0 件のコメント:

コメントを投稿

注: コメントを投稿できるのは、このブログのメンバーだけです。