|
In the episode The Lesser of Two Evils of the television show Futurama,
the following exchange takes place:
Bender: Hey, brobot, what's your serial number?
Here is a program in C to find the cubes via brute force.
// CUBES.C // Find the sum of cubes // Last revised 11 June 2005 #include <stdio.h> #include <stdlib.h> #include <math.h> #define SN_FLEXO 3370318 #define SN_BENDER 2716057 int find_summed_cubes( int sum, int *cube_1, int *cube_2 ) { int c1, c2; int trial_sum; int trials; int difference; int offset; int start_value; start_value = (int) sqrt( (float) sum ); trials = 0; for ( c1 = -start_value; c1 < start_value; c1++ ) { for ( c2 = -start_value; c2 < start_value; c2++ ) { trials++; trial_sum = c1 * c1 * c1 + c2 * c2 * c2; difference = trial_sum - sum; if ( 0 == difference ) { *cube_1 = c1; *cube_2 = c2; return( 0 ); } } } return( 1 ); } int main( void ) { int result; int cube_1, cube_2; result = find_summed_cubes( SN_FLEXO, &cube_1, &cube_2 ); if ( result ) printf( "Couldn't stumble across the roots.\n" ); else printf( "Flexo, SN %d = %d^3 + %d^3.\n", SN_FLEXO, cube_1, cube_2 ); result = find_summed_cubes( SN_BENDER, &cube_1, &cube_2 ); if ( result ) printf( "Couldn't stumble across the roots.\n" ); else printf( "Bender, SN %d = %d^3 + %d^3.\n", SN_FLEXO, cube_1, cube_2 ); }
$ ./cubes Flexo, SN 3370318 = 119^3 + 119^3. Bender, SN 3370318 = -951^3 + 952^3. $
|