The Fibonacci sequence is determined only by its first two elements; in fact, you could somehow parallelize it, albeit ugly:
F(n + 2) = F(n + 1) + F(n) F(n + 3) = F(n + 1) + F(n + 2) = F(n + 1) * 2 + F(n) F(n + 4) = F(n + 2) + F(n + 3) = F(n + 1) * 3 + F(n) * 2 F(n + 5) = F(n + 3) + F(n + 4) = F(n + 1) * 5 + F(n) * 3 F(n + 6) = F(n + 4) + F(n + 5) = F(n + 1) * 8 + F(n) * 5
Hope you can now see that:
F(n + k) = F(n + 1) * F(K) + F(n) * F(k - 1)
So, after calculating the first k numbers, you can use this ratio to calculate the next k elements in the sequence, at the same time, with parallelization.
You can also use the direct formula for Fibonacci numbers to calculate them in parallel, but this is too crude (it may also be too simple for training purposes that it can serve).
source share