1729 是在英国数学家 G的轶事之后的 Ramanujan编号。 H. Hardy 在医院探望印度数学家 Srinivasa Ramanujan 时。他说出了他们的谈话内容:
“我记得有一次他在普特尼生病时去看他。我曾骑过1729号出租车,并说这个数字对我来说似乎是个呆板,我希望这不是一个不利的预兆。”他回答说:“这是一个非常有趣的数字。它是可通过两种不同方式表示为两个立方体之和的最小数字。”
两种不同的方式是:
1729 = 1 ^ 3 + 12 ^ 3 = 9 ^ 3 + 10 ^ 3
(来源:https://en.wikipedia.org/wiki/1729_(number))
接下来的号码是 4104 。
4104 = 16 ^ 3 + 2 ^ 3 = 9 ^ 3 + 15 ^ 3
我想找到更多这样的数字。我尝试了几次,但无法为其编写代码。我编写的代码没有运行。
答案 0 :(得分:1)
尽管,您必须已经展示了您的作品。
试试吧:
#include <stdio.h>
int main(){
int i, a, b, x, y, k;
printf("Input nos. between which you want to find Ramanujan No.: ");
scanf("%d %d", &a, &b);
for(i=a;i<b;i++){
k=0;
for(x=1;x*x*x<i;x++){
for(y=x+1;x*x*x+y*y*y<=i;y++){
if(x*x*x+y*y*y==i){
k++;
x++;
}
}
}
if(k==2){
printf("%d ", i);
}
}
return 0;
}