2016年8月14日日曜日

160814(2)

Ruby


x^3 + y^3 = z^3 ± 1(2)

x^3 + y^3 = z^3 ± 1 を満たす自明でない自然数 (x, y, z) の組を探してみた。

n = 5000
(1..n).each{|i|
  (i - 1).downto(1){|j|
    k = i ** 3 - j ** 3 + 1
    l = (k ** (1.0 / 3)).round
    break if l > j
    p [l, j, i, l ** 3 + j ** 3 == i ** 3 + 1] if l ** 3 == k
  }
}
p ''
(1..n).each{|i|
  (i - 1).downto(1){|j|
    k = i ** 3 - j ** 3 - 1
    l = (k ** (1.0 / 3)).round
    break if l > j
    p [l, j, i, l ** 3 + j ** 3 == i ** 3 - 1] if l ** 3 == k
  }
}

出力結果
[9, 10, 12, true]
[64, 94, 103, true]
[73, 144, 150, true]
[135, 235, 249, true]
[334, 438, 495, true]
[244, 729, 738, true]
[368, 1537, 1544, true]
[1033, 1738, 1852, true]
[1010, 1897, 1988, true]
[577, 2304, 2316, true]
[3097, 3518, 4184, true]
""
[6, 8, 9, true]
[71, 138, 144, true]
[135, 138, 172, true]
[372, 426, 505, true]
[426, 486, 577, true]
[242, 720, 729, true]
[566, 823, 904, true]
[791, 812, 1010, true]
[236, 1207, 1210, true]
[575, 2292, 2304, true]
[1938, 2820, 3097, true]
[2676, 3230, 3753, true]

0 件のコメント:

コメントを投稿