Part A:
DEFDBL A-Z
OPEN "ramanuj.txt" FOR OUTPUT AS #2
FOR a = 1 TO 1000
a3 = a * a * a
FOR b = a TO 1000
b3 = b * b * b
v = a3 + b3
PRINT #2, USING "#### #### ###########"; a; b; v
NEXT
NEXT
CLOSE
Then, the ramanuj.txt file was sorted on the total value (v), and read by the following program:
OPEN "ramanuj.txt" FOR INPUT AS #1
CLS
DO
pprevl$ = prevl$
prevl$ = l$
LINE INPUT #1, l$
pprevn$ = prevn$
prevn$ = n$
n$ = MID$(l$, 12, 10)
IF n$ = pprevn$ THEN
IF flag = 0 THEN PRINT pprevl$: PRINT prevl$: ct = ct + 2
flag = 1
PRINT l$: ct = ct + 1
ELSE
IF flag THEN PRINT : ct = ct + 1
IF ct > 40 THEN ct = 0: DO: LOOP UNTIL INKEY$ > ""
flag = 0
END IF
LOOP UNTIL EOF(1)
CLOSE
which found the following as the first few values that each had three ways of being produced by the sum of positive cubes (the cube roots of the cubes are shown, together with the sum of the cubes):
167 436 87539319
228 423 87539319
255 414 87539319
11 493 119824488
90 492 119824488
346 428 119824488
359 460 143604279
408 423 143604279
111 522 143604279
315 525 175959000
70 560 175959000
198 552 175959000
300 670 327763000
339 661 327763000
510 580 327763000
510 828 700314552
334 872 700314552
456 846 700314552
295 920 804360375
15 930 804360375
198 927 804360375
692 856 958595904
22 986 958595904
180 984 958595904
Part B:
DEFDBL A-Z
OPEN "ramanub.txt" FOR OUTPUT AS #2
FOR a = -1000 TO 1000
a3 = a * a * a
FOR b = ABS(a) TO 1000
b3 = b * b * b
v = a3 + b3
PRINT #2, USING "##### ##### ###########"; a; b; v
NEXT
NEXT
CLOSE
Then, the ramanuB.txt file was sorted on the total value (v), and zero values eliminated, and read by the following program:
OPEN "ramanub.txt" FOR INPUT AS #1
CLS
DO
pprevl$ = prevl$
prevl$ = l$
LINE INPUT #1, l$
pprevn$ = prevn$
prevn$ = n$
n$ = MID$(l$, 14, 10)
IF n$ = prevn$ THEN
IF flag = 0 THEN PRINT prevl$: ct = ct + 1
flag = 1
PRINT l$: ct = ct + 1
ELSE
IF flag THEN PRINT : ct = ct + 1
IF ct > 40 THEN ct = 0: DO: LOOP UNTIL INKEY$ > ""
flag = 0
END IF
LOOP UNTIL EOF(1)
CLOSE
Results include not only the first few sums of two cubes in two ways but also the first achievable in three ways: 728. The results are shown to the first one that's beyond Ramanujan's 1729:
3 4 91
-5 6 91
-4 6 152
3 5 152
-3 6 189
4 5 189
1 6 217
-8 9 217
-6 9 513
1 8 513
-2 9 721
-15 16 721
-10 12 728
6 8 728
-1 9 728
-9 12 999
-1 10 999
-18 19 1027
3 10 1027
-8 12 1216
6 10 1216
-6 12 1512
8 10 1512
9 10 1729
1 12 1729
-16 18 1736
2 12 1736
9 12 2457
-15 18 2457
|
Posted by Charlie
on 2010-08-02 16:03:48 |