Why is my Swift loop failing with error “Can't form range with end < start”?

后端 未结 6 1734
北海茫月
北海茫月 2021-02-05 01:44

I have a for loop that checks if a number is a factor of a number, then checks if that factor is prime, and then it adds it to an array. Depending on the original number, I wil

6条回答
  •  天命终不由人
    2021-02-05 02:03

    If you want to use range where upperBound < lowerBound, you can add reversed() to it.

    for eg: for number in (0...highestPossibleNumber).reversed()

提交回复
热议问题