Wednesday 12 June 2024

Solution to Maths Problem no 3

I worked this out using the program below. The solution is at the bottom of the page:

andrew@ASUS-Laptop:~/Maths_Problems$ cat problem1.c
#include <math.h>
#include <stdio.h>
int main ()
{
int abc;
int def;
double abcdef;
double square_root;
int solution;
for(abc=100; abc<=998; abc++)
  {
  def=abc+1;
  abcdef=(1000*abc)+def;
  square_root=trunc(pow(abcdef,0.5));
  if(pow(square_root, 2)==abcdef)
    {
    solution=abcdef;
    printf("%d\n",solution);
    }
  }
return 0;
}
andrew@ASUS-Laptop:~/Maths_Problems$ ./problem1
183184
328329
528529
715716
andrew@ASUS-Laptop:~/Maths_Problems$

No comments:

Post a Comment