 /**
 	Works with the Sieve of Eratosthenes.
 */
-public func primesTo(n: Int) -> [Int]
+public func primesTo(_ n: Int) -> [Int]
 {
 	if n < 2 { return [] }
 
-	var A = BitField(count: n + 1, repeated: true)
+	var A = BitField(repeating: true, size: n)
 
 	var i = 2
 	while i * i <= n
 	{
-		if A.get(i)
+		if A[i - 1]
 		{
 			var j = i * i
 			var c = 1
 			while j <= n
 			{
-				A.set(j, b: false)
+				A[j - 1] = false
 				j = i * (i + c)
 				c += 1
 			}

/**
	Returns the n-th prime number.
*/
func getPrime(n: Int) -> Int
{
	if n < 1 { forceException("There is no 0-th prime number") }

	var prime = 2
	var primeCount = 1

/*
	————————————————————————————————————————————————————————————
	BasicMath.swift
	————————————————————————————————————————————————————————————
	Created by Marcel Kröker on 03.04.15.
	Copyright (c) 2015 Blubyte. All rights reserved.
*/

import Foundation

func binomial(_ n: Int, _ k: Int) -> Int
{
	return k == 0 ? 1 : n == 0 ? 0 : binomial(n - 1, k) + binomial(n - 1, k - 1)
}

func kronecker(_ i: Int, j: Int) -> Int
{
	return i == j ? 1 : 0
}

func numlen(_ n: Int) -> Int
{
	if n == 0 { return 1 }
	return Int(log10(Double(abs(n)))) + 1
}

func isPrime(_ n: Int) -> Bool
{
	if n <= 3 { return n > 1 }

