Monday 17 June 2024
Sudoku no 733 (Easy)
Our younger son created this puzzle using a Javascript program which he wrote himself:
Saturday 15 June 2024
Solution to Maths Problem no 5
To solve this problem, I looked up pi to several decimal places then worked it out by trial and error with the PL/SQL code below:
SQL> @pi
SQL> set serveroutput on
SQL> declare
2 top number;
3 bottom number;
4 pi constant number := 3.141592654;
5 ratio number;
6 difference number;
7 save_difference number := 1;
8 save_top number;
9 save_bottom number;
10 save_ratio number;
11 begin
12 for top in 1..999 loop
13 for bottom in 1..999 loop
14 ratio := top/bottom;
15 difference := abs(pi-ratio);
16 if difference < save_difference then
17 save_difference := difference;
18 save_top := top;
19 save_bottom := bottom;
20 save_ratio := ratio;
21 end if;
22 end loop;
23 end loop;
24 dbms_output.put_line('Top: '||save_top);
25 dbms_output.put_line('Bottom: '||save_bottom);
26 dbms_output.put_line('Ratio: '||save_ratio);
27 end;
28 /
Top: 355
Bottom: 113
Ratio: 3.14159292035398230088495575221238938053
PL/SQL procedure successfully completed.
SQL>
So there you have it. The best fractional approximation to pi with a 3 digit numerator and denominator is 355/113, which is accurate to 6 decimal places i.e. 3.141593.
Maths Problem no 5
3.14 and 22/7 are both approximations for pi (or π).
22/7 is a fraction with a 2 digit numerator and a 1 digit denominator.
Find the best fractional approximation for pi with a 3 digit numerator and denominator.
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$
Maths Problem no 4
Find a six digit positive integer abcdef where:
abcdef = a^6 + b^6 + c^6 + d^6 + e^6 + f^6.
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$
Maths Problem no 3
Find all 6 digit integers ABCDEF such that:
(1) ABCDEF is a perfect square.
(2) DEF = ABC + 1.