2005 math problem
From: uthman (o_masud_at_yahoo.com)
Date: 01/15/05
- Next message: george ghiata: "HOW ARCHIMEDES PROVED FERMAT LAST THEOREM!!!"
- Previous message: Madhusudan Singh: "Integral equations"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 15 Jan 2005 14:52:59 +0000 (UTC)
Concerning the 2005 math problem ( which asks to use adding,
subtracting, dividing, multiplying, exponentiating, square-rooting,
making decimal numbers, factorials, and concatenating numbers [like
making 1 and 2 into 12 or 21] with the digits 2005 to make the
integers 1-100), does anyone know of an efficient algorithm to do
this? Mine involves making many loops; 1 for the numbers 1-100, 4 for
the different input values of the functions, and 3 for the functions
themselves.
Please see below code:
Notes: max_number_to_solve is in this case 100. the f_2 function takes
in three parameters: the first number, the second number, and the
function number. The function number indicates what function to use
(adding, subtracting, etc.) while the first and second numbers are
inputs to the function. There are 12 positions in the vector
"digits[]" because 4 take up "2005", 4 more take up the factorials of
each of those digits, 4 more take up the square roots of each of those
digits, and 1 takes up the null character. It starts at digits[0],
which is "2" if the year is "2005".
If anyone wants the full program (I think it works) e-mail me at
o_masud@yahoo.com
(uses c++)
for(x=1;x <=max_number_to_solve;x++){//to obtain answers
for(int a = 0; a <= 11; a++){// for 12 digits:1st var
for(int b=0; b<=11; b++){// for 12 digits: 2nd var
for(int c=0;c<=11;c++){// " ": 3rd var
for(int d=0;d<=11;d++){// " ": 4th var
for(int e=0;e<=6;e++){// 7 2-parameter functions
for(int f=0;f<=6;f++){// 7 2-paramter functions
for (int g=0;g<=6;g++){// 7 2-parameter functions
// 0-6 correspond to a function #
if (x==( f_2(f_2(a,b,e), f_2(c,d,f), g) ) && nonrepeating(a,b,c,d)
&& !found[x]) {
outfile<<x<<"= [" << g << "]( [" << e << "] ("<< a <<","<<b<<"),
["<<f<<"]("<<c<<","<<d<<") )"<<endl;
found[x]=true;
}
}}}}}}}}
Thanks
- Next message: george ghiata: "HOW ARCHIMEDES PROVED FERMAT LAST THEOREM!!!"
- Previous message: Madhusudan Singh: "Integral equations"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|