Friday, February 28, 2014
Second Factorial Program
Most programs like these do not require much analysis. In fact, programs whose main job is to compute algorithms, and that’s it -, the challenge comes from actually developing the algorithm, not analysing. In this program, I could easily describe the step by step process of the program, and why it actually works, but that wouldn’t get me anywhere. (I had not actually come up with this code; I’ve cheated out of frustration into finding the algorithm for a factorial.) Let this serve as a lesson. Nevermind, i just noticed that the algorithm doesn’t return the correct answers. Time for a fix! I’ve fixed it on my own :), and it was a lot easier than expected… WHy had I struggled with this before? First, I made sure to take care of 1 and 2, since well.. I could make an algorithm that works without the if and else statements but I’d prefer just to continue. First I made sure that the range of my algorithm includes all the numbers and multiples of the factorials that I need to calculated. ‘n+1’ solved this. Next, ‘fact’ was redefined continuously throughout the input, as it continued through the list of the range of numbers.
Labels:
Python
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment