Abstract
Generating the Fibonacci sequence: 1, 1, 2, 3, 5, 8, 13, and so forth.
This file provides both parallel and sequential implementations. In practice, the sequential implementations are probably preferable in all realistic cases, as the integers storing the Fibonacci numbers will overflow far before enough parallelism is available.
Synopsis
Description
- ↑val fibs: (n: i64) -> [n]i32
Generate the first
n
Fibonacci numbers using a parallel algorithm.Work: O(n)
Span: O(log(n))
- ↑val fib: (n: i64) -> i32
Generate the
n
th Fibonacci number (0-indexed) using a parallel algorithm. Specifically,fib n == last (fibs (n+1)
, butfib
is more efficient. However,fib_seq
is likely even more efficient.Work: O(n)
Span: O(log(n))