100!
I remember the first challenging program we had to write in university was to compute the exact value of 100! (Factorial). Factorial is a value calculated by multiplying the number by the Factorial of previous number. For example 5! = 5 * 4! . The challenge is that in no programming language you can have a number with 70-80 digits, it's just too big. For such big numbers , programming languages use double values which can keep a number using precision format (by using decimal point and scientific presentation).We were told to write a program that could calculate the exact digits,all of them. Mr. Rahimi, our instructor who was my best teacher in university had given us this program to write and at the time I didn't have any computer. The university provided computers but not enough and this was not all we had to do for the week. So I and friend hired a computer for two hours and wrote the program. Each went his own way, the result was very interesting. I somehow came up with a simple algorithm that did the job in 7 lines of program code. Meanwhile my friend's code was more than 300 lines.Good old days...

0 Comments:
Post a Comment
<< Home