document.write( "Question 24809: how would you solve for n if you know what n! was?\r
\n" );
document.write( "
\n" );
document.write( "\n" );
document.write( "Thanks,
\n" );
document.write( "James \n" );
document.write( "
Algebra.Com's Answer #13261 by kev82(151) ![]() You can put this solution on YOUR website! Hi James,\r \n" ); document.write( "\n" ); document.write( "This is actually a really interesting question, I've spent most of this evening on it and although I've come up with some algorithms that get quite a good estimate, I havn't managed to get an exact solution.\r \n" ); document.write( "\n" ); document.write( "I don't want to baffle you with some really difficult maths, so I won't say too much without knowing how far you are in school/university. I took four different approaches and here's what I came up with. If you would like to hear about any of them in detail then please email back, and tell me how much maths you know, and I'll try to explain them.\r \n" ); document.write( "\n" ); document.write( "Let \n" ); document.write( "\n" ); document.write( "1) Prime factorisation - Calculate the power of 2 in the prime factorisation of x, and call it p. Clearly \n" ); document.write( "\n" ); document.write( "If you have a quick method for calculating prime factorisations (I'm thinking dynamic programming) then you could just start at 2 and subtract the powers of each natural's factorisation until you get one. At that point you've found n.\r \n" ); document.write( "\n" ); document.write( "2) Take logs, and realise that \n" ); document.write( "\n" ); document.write( "3) Use the left and right rectangle estimates of \n" ); document.write( "\n" ); document.write( " \n" ); document.write( "\n" ); document.write( "Using Newton-Raphson method you can solve the middle expression equal to log x. Then either floor(f) or ceil(f) is going to be your answer(I think I've proved this but it was very difficult, so might have made a mistake, regardless f is gonna be pretty close to n). The initial value for Newton-Raphson comes from stage one. To see what the convergence was like I tried a starting value of f=28 for 20! and I got to 20 almost immediatly, so it's pretty forgiving if you're wrong.\r \n" ); document.write( "\n" ); document.write( "4) The Gamma function is the Complex extension of factorial. So any inverse of the Gamma function over naturals should be an inverse for factorial. I wouldn't be too hopeful with this idea though, have you seen the Gamma function!\r \n" ); document.write( "\n" ); document.write( "Hopefully I've not confused you too much, but this is a very difficult question to answer. If you don't know calculus then ignore number 3&4, if you like computers then ask your teacher/lecturer about logorithms and try approach 2. Else learn about the fundamental theorem of arithmatic and try appproach one.\r \n" ); document.write( "\n" ); document.write( "I doubt it, but I hope that was helpful in some way. I thought it better to write something than leave the question unanswered.\r \n" ); document.write( "\n" ); document.write( "Kev \n" ); document.write( " |