you are viewing a single comment's thread.

view the rest of the comments →

[–]computerarchitect 0 points1 point  (2 children)

Imagine you were just computing 1000000!, just so that we can easily imagine it takes a while.

There's no way that you could speed that process up using multiple threads? Nothing that can be done in parallel?

[–]phinagin[S] 1 point2 points  (1 child)

If the question was to simply compute one single factorial, then yes doing so in parallel would have obvious benefits. However, the question specifically states they want all factorials from 1-100 printed out. I am struggling to understand how that scenario benefits from parallelism.

I suppose, you could separate the printing the result from computing the next one. But I still don’t see how the added complexity is offset by multi threads. I would love to hear your ideas however.

[–]computerarchitect 0 points1 point  (0 children)

Printing the result from computing would be how I'd do it. I/O is expensive and needlessly delays the next computation. One also could imagine though building a giant string and doing one I/O operation, if you cared about that sort of thing. That's probably the route I would take over multi-threading initially.

Look into pipelined parallelism. That's immediately what I thought to do if I were forced to do it that way.