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, 21.06.2019 22:00
Match the steps of the process to julia's analysis. 1. analyze choices. current costs for making phone calls to foreign countries averages between five and ten cents a minute. 2. determine the goals. julia needs to reduce the cost of telecommunications without reducing her employees' ability to do their jobs. 3. gather data. the corporate computer network will be able to handle the increased traffic that will occur as a result of voip. 4. evaluate the decision. julia will have her it department set up voip in the smallest domestic office. 5. make the decision. julia will have employees document the benefits and problems that result from using the new technology.
Answers: 1
question
Computers and Technology, 22.06.2019 18:30
Kto rozmawia z clamentain przez krótkofalówke w the walking dead która śledzi lee w 4 epizodzie
Answers: 1
question
Computers and Technology, 23.06.2019 01:00
Write the command that can be used to answer the following questions. (hint: try each out on the system to check your results.) a. find all files on the system that have the word test" as part of their filename. b. search the path variable for the pathname to the awk command. c. find all files in the /usr directory and subdirectories that are larger than 50 kilobytes in size. d. find all files in the /usr directory and subdirectories that are less than 70 kilobytes in size. e. find all files in the / directory and subdirectories that are symbolic links. f. find all files in the /var directory and subdirectories that were accessed less than 60 minutes ago. g. find all files in the /var directory and subdirectories that were accessed less than six days ago. h. find all files in the /home directory and subdirectories that are empty. i. find all files in the /etc directory and subdirectories that are owned by the group bin."
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
Who can provide you with a new password when you have forgotten your old one? your provide you with a new password in case you forget your old one.
Answers: 3
You know the right answer?
/** * Ramanujan. java
*
* S. Ramanujan was an Indian mathematician who became famous fo...
Questions
Questions on the website: 13722360