how to find the smallest taxicab number or Ramanujan number like 1729 larger than N?

1 Ansicht (letzte 30 Tage)
I write a .m file to find the a b c d of a taxicab number. The program run well when the num=1729 or some other taxicab number.
But when the num is not a taxicab, the program reture a empty.
I want to know how to find the smallest number large than for example 40000 and find the a b c d
And how to find the first few of taxicab number?
a^3+b^3=c^3+d^3
Your help would be highly appreciated!
clear
format long
num=1729;
b = 1:(num)^(1/3);
a = (num-b.^3).^(1/3);
condition=round(a,10)==round(a,5);
terms = find(condition);
taxicab=round(a(terms));

Akzeptierte Antwort

David Hill
David Hill am 24 Okt. 2022
There are so few taxicab numbers that you should just use a lookup table.
l=["2", "1729", "87539319", "6963472309248", "48988659276962496", "24153319581254312065344"];
  3 Kommentare
David Hill
David Hill am 24 Okt. 2022
Bute force
[a,b]=meshgrid(1:500);
t=a.^3+b.^3;
u=unique(t);
h=histc(t(:),u);
f=find(h==6);
min(u(f))
ans = 87539319

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Biological and Health Sciences finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by