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

조회 수: 1 (최근 30일)
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));

채택된 답변

David Hill
David Hill 2022년 10월 24일
There are so few taxicab numbers that you should just use a lookup table.
l=["2", "1729", "87539319", "6963472309248", "48988659276962496", "24153319581254312065344"];
  댓글 수: 3
David Hill
David Hill 2022년 10월 24일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Biological and Health Sciences에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by