https://github.com/nuclearace/swiftbiginteger
Swift Wrapper for LibTomMath
https://github.com/nuclearace/swiftbiginteger
Last synced: 4 months ago
JSON representation
Swift Wrapper for LibTomMath
- Host: GitHub
- URL: https://github.com/nuclearace/swiftbiginteger
- Owner: nuclearace
- Created: 2015-07-01T15:35:55.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-05-29T16:45:57.000Z (about 8 years ago)
- Last Synced: 2025-01-19T16:49:00.937Z (6 months ago)
- Language: Swift
- Homepage:
- Size: 129 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
```swift
import SwiftBigIntfunc fib(n: BigInteger) -> BigInteger {
if n < 2 {
return n
}var fibPrev = BigInteger(int: 1)
var fib = BigInteger(int: 1)
var num = BigInteger(int: 2)repeat {
(fibPrev, fib) = (fib, fib + fibPrev)
num += 1
} while num < nreturn fib
}print(fib(BigInteger(int: 100000)))
```
Install:- Install libtommath to /usr/local/
- Add `.Package("https://github.com/nuclearace/SwiftBigInteger", majorVersion: 1)` as a dependency.
- Add `-Xlinker -L/usr/local/lib -Xcc -I/usr/local/include` to your build command.