Effacer les filtres
Effacer les filtres

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

4 vues (au cours des 30 derniers jours)
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));

Réponse acceptée

David Hill
David Hill le 24 Oct 2022
There are so few taxicab numbers that you should just use a lookup table.
l=["2", "1729", "87539319", "6963472309248", "48988659276962496", "24153319581254312065344"];
  3 commentaires
David Hill
David Hill le 24 Oct 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
Daniel Niu
Daniel Niu le 24 Oct 2022
Thank you for your answer,David.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Biological and Health Sciences dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by