Flash Speed Questions

The solution time is much shorter than you think.

/** * 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 &lt;= n; a++) { a3 = a * a * a; if (a3 &gt; n) break; for (b = a; b &lt;= n; b++) { b3 = b * b * b; if (a3 + b3 &gt; n) break; for (c = a + 1; b &lt;= n; c++) { c3 = c * c * c; if (c3 &gt; a3 + b3) break; for (d = c; d &lt;= n; d++) { d3 = d * d * d; if (c3 + d3 &gt; 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(); } } } } } } } Get the answer
Category: business | Author: Sagi Boris

Related Questions

/*question: how many times are the statements first semester and sec
literature5 Minutes ago
// * answer with details* // quadrilateral abcd is inscribed in a circ
womensstudies7 Minutes ago
// answer pls // which of the following statements is true about mino
statistics12 Minutes ago

mechanicalengineering

Abraham Uilleam 55 Minutes ago

// marian basting takes in small sewing jobs. // she has two files sorted by date. // (the date is composed of two numbers -- month and year.) // one

biomedicalengineering

Sarah Aksinia 1 Hours ago

// please answer // how are plants called epiphytes adapted to living in the understory of a rainforest? a.) they have waxy leaves. b.) they lose the

science

Ehud Raghnall 1 Hours ago

// please answer \\ what is missing in the alpine tundra that is present in the arctic and antarctic tundra? a.) animals b.) permafrost c.) trees d.)