Exercise 3.71: Numbers that can be expressed as
the sum of two cubes in more than one way are sometimes called
Ramanujan numbers, in honor of the mathematician Srinivasa
Ramanujan. Ordered streams of pairs provide an elegant
solution to the problem of computing these numbers. To find a number that can
be written as the sum of two cubes in two different ways, we need only generate
the stream of pairs of integers (
i
,
j
) weighted according to the sum
i
3
+
j
3 (see Exercise 3.70), then search the stream for two
consecutive pairs with the same weight. Write a procedure to generate the
Ramanujan numbers. The first such number is 1,729. What are the next five?
练习 3.71:能以多于一种方式表示为两个立方数之和的数,有时被称为 Ramanujan 数,以纪念数学家 Srinivasa Ramanujan。有序的序对流为计算这些数提供了一种优雅的解法。要找到一个能以两种不同方式写成两个立方数之和的数,只需生成按 i³ + j³ 加权排序的整数序对 (i, j) 的流(参见练习 3.70),然后在流中寻找两个权值相同的连续序对即可。请写一个过程来生成所有 Ramanujan 数。第一个这样的数是 1,729。接下来的五个是什么?