Added factorial test

This commit is contained in:
Adam Fowler 2019-11-20 01:37:34 +00:00
parent eec1799404
commit f73c2d1aca
1 changed files with 13 additions and 0 deletions

View File

@ -182,6 +182,19 @@ final class BigNumTests: XCTestCase {
XCTAssert(r.isPrime(numChecks:128))
}
func testFactorial() {
var factorial = BigNum(1)
for i in 1..<1000 {
factorial = factorial * BigNum(i)
}
print(factorial)
for _ in 1..<100 {
let random = BigNum.psuedo_random(max: BigNum(1000))
XCTAssertEqual(BigNum.gcd(random, factorial), random)
}
}
static var allTests = [
("testConversion", testConversion),
("testBasic", testBasic),