Coffee Room

Discuss anything here - everything that you wish to discuss with fellow engineers.

12796 Members

Join this group to post and comment.

# Find integers a, b & c - of course, if you can!

Find integers a, b and c such that :-

There are (at least) 3 solutions with a and b non-zero.

987654321a + 123456789b + c = (a + b + c)³

There are (at least) 3 solutions with a and b non-zero.

Can "C" be more than 1 digit number ?

I don't know, seriously.

put three for loops each iterating from 0 to 9 and check the condition above.

Manually i dont think i can find it.

Here is the programme.

Disclaimer: The synatx may not be proper.

for(a=0;a<=9;a++)

{

for(b=0;b<=9;b++)

{

for(c=0;c<=9;c++)

{

int a1 = 9876543210 + a;

int a2 =1234567890 + b;

int cube = Math.pow((a+b+c),3);

int Sum = a1 + a2;

int result = a1.compareTo(a2);

if (result ==0)

{

syso(a,b,c);

}else

continue;

}

}

}

Manually i dont think i can find it.

Here is the programme.

Disclaimer: The synatx may not be proper.

for(a=0;a<=9;a++)

{

for(b=0;b<=9;b++)

{

for(c=0;c<=9;c++)

{

int a1 = 9876543210 + a;

int a2 =1234567890 + b;

int cube = Math.pow((a+b+c),3);

int Sum = a1 + a2;

int result = a1.compareTo(a2);

if (result ==0)

{

syso(a,b,c);

}else

continue;

}

}

}

450 * 987654321 + 4500 * 123456789 + 5050 = (450+4500+5050) ^ 3 = 1000000000000

7350 * 987654321 + 6000 * 123456789 + 6650 = (7350+6000+6650) ^ 3 = 8000000000000

but what is the trick ???😕

7350 * 987654321 + 6000 * 123456789 + 6650 = (7350+6000+6650) ^ 3 = 8000000000000

but what is the trick ???😕

**My Program found 4 results. First three found with in 1 Min 48 seconds. Total scan took 7 Min 19 seconds.**

**Result:**

{0, 0, 1} - 0 Sec

{450, 4500, 5050} - 6 Sec

{7350, 6000, 6650} - 1 Min 48 Sec

{27150, 1500, 1350} - 6 Min 24 Sec

**Program:**

void main()

{

unsigned long double LHS, RHS, Duration;

int a, b, c, Left, Right;

time_t Start, Stop;

time( &Start );

for( a = 0; a < 31427; a++ )

{

for( b = 0; b < 31427; b++ )

{

Left = 0;

Right = 31428;

while( Left < ( Right - 1 ))

{

c = ( Left + Right ) / 2;

LHS = unsigned long double(a) * 987654321;

LHS += unsigned long double(b) * 123456789;

LHS += unsigned long double(c);

RHS = unsigned long double( a + b + c );

RHS = RHS * RHS * RHS;

if( LHS == RHS )

{

printf("\n\n987654321*%d + 123456789*%d + %d = %.0Lf\n", a, b, c, LHS);

printf("(%d + %d + %d)^3 = %.0Lf\n", a, b, c, RHS);

printf("987654321*%d + 123456789*%d + %d = (%d + %d + %d)^3\n\n", a, b, c, a, b, c);

break;

}

if( LHS < RHS )

{

Right = c;

}

else

{

Left = c;

}

}

}

time( &Stop );

Duration = difftime( Stop, Start );

int Seconds = (int)fmod( Duration, 60 );

int Minutes = (int)fmod( floor(Duration / 60), 60 );

int Hours = int(Duration / 3600);

printf("\rCompleted:%0.1Lf%%", (a * 100.) / 31427);

printf("\tElapsed Time:%02d:%02d:%02d", Hours, Minutes, Seconds);

}

}

**Output:**

987654321*0 + 123456789*0 + 1 = 1

(0 + 0 + 1)^3 = 1

987654321*0 + 123456789*0 + 1 = (0 + 0 + 1)^3

Completed:1.4% Elapsed Time:00:00:06

987654321*450 + 123456789*4500 + 5050 = 1000000000000

(450 + 4500 + 5050)^3 = 1000000000000

987654321*450 + 123456789*4500 + 5050 = (450 + 4500 + 5050)^3

Completed:23.4% Elapsed Time:00:01:48

987654321*7350 + 123456789*6000 + 6650 = 8000000000000

(7350 + 6000 + 6650)^3 = 8000000000000

987654321*7350 + 123456789*6000 + 6650 = (7350 + 6000 + 6650)^3

Completed:86.4% Elapsed Time:00:06:24

987654321*27150 + 123456789*1500 + 1350 = 27000000000000

(27150 + 1500 + 1350)^3 = 27000000000000

987654321*27150 + 123456789*1500 + 1350 = (27150 + 1500 + 1350)^3

Completed:100.0% Elapsed Time:00:07:19

Superb Solution Fazil.