Question: Write a C# program that asks a user for a whole number and prints out the factorial of that number. The program should use three

Write a C# program that asks a user for a whole number and prints out the factorial of that number. The program should use three threads (or tasks) to complete the computation. One thread computes the factorial upto first third, the second thread should compute the factorial of the middle third, and the third thread computes factorial of the last third. A final thread multiplies all three results to get the final answer. For example, to compute 25!:

25 divided into three approximately equal parts = 8+8+9

Thread1 (or Task1): Result1 = 1*2*3*4*5*6*7*8

Thread2 (or Task2): Result2 = 9*10*11*12*13*14*15*16

Thread3 (or Task3): Result3 = 17*18*19*20*21*22*23*24*25

Final result (Thread/Task4) = Result1*Result2*Result3

Print Final result.

Compare the result of computing the factorial by using a sequential loop and printing the answer.

Which method is faster?

How did you determine which method is faster?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!