subject

/** * Ramanujan. java
*
* S. Ramanujan was an Indian mathematician who became famous for his intuition
* for numbers. When the English mathematician G. H. Hardy came to visit him in
* the hospital one day, Hardy remarked that the number of his taxi was 1729, a
* rather dull number. To which Ramanujan replied, "No, Hardy! No, Hardy! It is
* a very interesting number. It is the smallest number expressible as the sum
* of two cubes in two different ways."
* Verify this claim by writing a program Ramanujan. java that takes a command
* line argument N and prints out all integers less than or equal to N that can
* be expressed as the sum of two cubes in two different ways - find distinct
* positive integers a, b, c, and d such that a^3 + b^3 = c^3 + d^3. Use four
* nested for loops.
*/
public class Ramanujan {
public static void main(String args[]) {
int N = Integer. parseInt(args[0]);
int a, b, c, d, a3, b3, c3, d3;
for (a = 1; a <= N; a++) {
a3 = a * a * a;
if (a3 > N) break;
for (b = a; b <= N; b++) {
b3 = b * b * b;
if (a3 + b3 > N) break;
for (c = a + 1; b <= N; c++) {
c3 = c * c * c;
if (c3 > a3 + b3) break;
for (d = c; d <= N; d++) {
d3 = d * d * d;
if (c3 + d3 > a3 + b3) break;
if (c3 + d3 == a3 + b3) {
System. out. print((a3+b3) + " = ");
System. out. print(a + "^3 + " + b + "^3 = ");
System. out. print(c + "^3 + " + d + "^3");
System. out. println();
}
}
}
}
}
}
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 09:10
  to change the number of rows and columns displayed by the excel object a. select the object and drag a size handle on the active object. b. deselect the object and drag a size handle of the object. c. deselect the object and drag a row or column divider of the object. d. select the object and drag a row or column divider on the active object.
Answers: 2
question
Computers and Technology, 24.06.2019 16:30
Jenny needs to record the names of 30 students, write down the subjects they studied, and note their grades in each subject after the midsemester exams and the end-of-semester exams. she divides the midsemester and end-of-semester information into two separate worksheets, sheet 1 and sheet 2. how will she rename the two worksheets?
Answers: 2
question
Computers and Technology, 25.06.2019 09:30
Evaluate the following code segment. what is the value of count after execution? int count = 1; for(int outer = 0; outer < 4; outer++) for(int inner = 1; inner < 3; inner++) count++; 1 3 9 12 13
Answers: 1
question
Computers and Technology, 25.06.2019 16:30
If your job involves creating a positive image for a company in the media, what would your job description be?
Answers: 1
You know the right answer?
/** * Ramanujan. java
*
* S. Ramanujan was an Indian mathematician who became famous fo...
Questions
question
Mathematics, 04.09.2020 03:01
question
Mathematics, 04.09.2020 03:01
question
Chemistry, 04.09.2020 03:01
question
Mathematics, 04.09.2020 03:01
question
Social Studies, 04.09.2020 03:01
question
Mathematics, 04.09.2020 03:01