 	{
 		for i in range
 		{
-			letters.append(String(UnicodeScalar(i)))
+			letters.append(String(describing: UnicodeScalar(i)))
 		}
 	}
 

	}
	
	return res
} // returns random String with length len

func fibIter(x: Double) -> Double // Iterative Fibonacci
{
    let s5 = sqrt(5.0)
    
    let p1 = 1.0 / s5
    let p2 = (1 + s5) / 2.0
    let p3 = (1 - s5) / 2.0
    
    return p1 * (pow(p2, x) - pow(p3, x))
}


func collatz(n: Int) -> Int
{
	var n = n
    var heap = [0,0]
    
    let s = n
    var runs = 0
    
    while n > 1
    {
        if n < s
        {
            let new = runs + heap[n]
            heap.append(new)
            return new
        }
        
        runs += 1
        
        if n % 2 == 0
        {
            let nn = n / 2
            
            n = nn
        }
        else
        {
            let nn = (3 * n) + 1
            
            n = nn
        }
    }
    
    if heap.count <= s
    {
        heap.append(runs)
    }
    
    return runs
}

func collatzSimple(n: Int) -> Int
{
	var n = n
    var runs = 0

    while n > 1
    {
        runs += 1
        if n % 2 == 0
        {
            let nn = n / 2
            n = nn
        }
        else
        {
            let nn = (3 * n) + 1
            n = nn
        }
    }
    return runs
}

func col(n: Int)
{
	var provenBound = 2 // 4,2,1


	while provenBound < n
	{
		var index = provenBound + 1

		index = (3 * index) + 1
		index >>= 1

		while index > provenBound
		{
			if index & 1 == 0
			{
				index >>= 1
			}
			else
			{
				index = (3 * index) + 1
			}
		}
		provenBound += 2

	}
	print(provenBound)	
}

func monteCarloPi(n: Int) -> Double
{
    var dotsInCircle = 0
    
    for _ in 1...n
    {
        if sqrt(
			pow(  Double(arc4random()) / Double(UINT32_MAX), 2.0)
			+ pow(Double(arc4random()) / Double(UINT32_MAX), 2.0)
			)
			<= 1.0
        {
            dotsInCircle += 1
        }
    }
    
    return (Double(dotsInCircle * 4) / Double(n))
}

func gcd(a: Int, _ b: Int) -> Int
{
    if b == 0 { return a }
    return gcd(b, a % b)
}

func lcm(a: Int, _ b: Int) -> Int
{
    return (a / gcd(a, b)) * b
}

	i = 3
	while i <= n
	{
		if A[i - 1] { res.append(i) }
		i += 2
	}

	return res
}

func nextPrime( _ n: inout Int)
{
	repeat
	{
		n += 1
	}
	while !isPrime(n)
}

// Returns random Int within range
func random(_ range: Range<Int>) -> Int
{
    let offset = abs(range.lowerBound)
    
    let mini = UInt32(range.lowerBound + offset)
    let maxi = UInt32(range.upperBound + offset)
    
    return Int(mini + arc4random_uniform(maxi - mini)) - offset
}

// Returns array filled with n random Ints within range
func random(_ range: Range<Int>, _ count: Int) -> [Int]
{
	var res = [Int](repeating: 0, count: count)

    for i in 0..<count
    {
        res[i] = random(range)
    }
    return res
}
