减少功能错误迅速

时间:2016-02-21 12:48:29

标签: arrays swift sum reduce

var arrF = [1]

    var arrS = [1,2]

    var numbers = [1]

    let last = numbers.last

    var x = 1
    var equals = [1]

    while arrF.count < 63 {

        numbers.append((last! + 1))

        arrF.append(numbers.reduce(1, combine: *))

    }

    for (index, value) in arrF.enumerate() {

        arrF[index] = Int(sqrt(Double(value)))
    }

    while arrS.count < 63 {

        arrS.append(arrS.reduce(0, combine: +))

    }

    while x < 63 {

        let a = arrF[x]

        let b = arrS[x]

        if a == b {

            equals.append(a * a)
        }

        x++
    }

    print(equals)

上面的代码搜索因子数,其中平方根等于其原始因子的总和。它运行正常,但如果我在63之后继续循环,我会在reduce函数行中得到“Dab指令错误”。有谁知道如何解决这个问题,reduce函数是否有限制?

0 个答案:

没有答案