Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,155,788 members, 7,827,909 topics. Date: Tuesday, 14 May 2024 at 07:02 PM |
Nairaland Forum / Slysoft's Profile / Slysoft's Posts
(1) (of 1 pages)
Programming / Re: Simple Factorial Challenge by slysoft: 11:16am On Jun 01, 2016 |
@jacob05 Impressive script, i just learned something. The loop in your script started from 2 till 5001... can you explain why? |
Programming / Re: Simple Factorial Challenge by slysoft: 6:46pm On May 31, 2016 |
jacob05: Hi @jacob05, I designed the php script @slyrox uploaded for the problem... as @Lyphiard rightly mentioned that the problem @OP posted came from a competition in USA which we solved in our team before sharing it nairaland to develop other programmers on this platform. The accepted solution/result on the competition portal was "5.08845978368001251890" which is the same as the result of our script/algorithm and different from the solution/result of your script/algorithm "5.088459783680012467179075225". However, this is how we solved it or how we got the algorithm; Looking at the equation posted; x^2 + (5/3)x^3 + (23/12)x^4 + (119/60)x^5 ... + (2*[5000!-1]/[5000!])x^5000 it can easily be translated into a summation equation which is to sum the result of ((2 * ([a+1]! – 1) / [a+1]! ) * x^(a+1) from a = 1 till 5000 where x is a constant so for a = 1 we have x^2 a = 2 we have (5/3)x^3 sum the results till a = 5000 All we did was to translate the deduced summation equation into a script/algorithm. there was no reason behind using php, I could have used several other lang java, C#, VB, C, ruby, python The result of the problem was also requested in the nearest 20 decimal places. why i added bcscale(25) is to control the number of trailing digits after the decimal and not affect the integrity of the 20th digit after the decimal. then i took off the trailing 5 digits after the 20th decimal I will be willing to learn if you comeup with a much quicker or less-lame solution with regards to the posted problem. Thanks BTW, My understanding of your script is that 5000 = 5000!; correct me if i am wrong.
|
(1) (of 1 pages)
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 7 |