Friday 14 June 2024

Solution to Maths Problem no 4

The answer is 548834.

I used the program below to work it out:

andrew@ASUS-Laptop:~/Maths_Problems$ cat problem4e.c
#include <math.h>
#include <stdio.h>
int main()
{
double a;
double b;
double c;
double d;
double e;
double f;
int abcdef;
for(a=1;a<=9;a++)
  {
  for(b=0;b<=9;b++)
    {
    for(c=0;c<=9;c++)
      {
      for(d=0;d<=9;d++)
        {
        for(e=0;e<=9;e++)
          {
          for(f=0;f<=9;f++)
            {
            abcdef=100000*a+10000*b+1000*c+100*d+10*e+f;
            if (abcdef==pow(a,6)+pow(b,6)+pow(c,6)+pow(d,6)+pow(e,6)+pow(f,6))
              printf("%d\n",abcdef);
            }
          }
        }
      }
    }
  }

return 0;
}
andrew@ASUS-Laptop:~/Maths_Problems$

I ran it as follows:

andrew@ASUS-Laptop:~/Maths_Problems$ ./problem4e
548834
andrew@ASUS-Laptop:~/Maths_Problems$ 

...then I checked the result:

andrew@ASUS-Laptop:~/Maths_Problems$ echo "5^6+4^6+8^6+8^6+3^6+4^6"|bc
548834
andrew@ASUS-Laptop:~/Maths_Problems$

No comments:

Post a Comment