Created
July 4, 2020 14:40
-
-
Save alexreg/3702f72ca36291aa99738440334d949e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func tribonacci(_ signature: [Int], _ n: Int) -> [Int] { | |
| let signature = (signature[0], signature[1], signature[2]) | |
| return Array(sequence(first: signature, next: { (a, b, c) in | |
| (b, c, a + b + c) | |
| }).map { $0.0 }.prefix(n)) | |
| } | |
| print(tribonacci([1, 1, 1], 5)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment