Find Factors of given number in swift 3.0

Code:
import UIKit

var n = 12

print("Factors of \(n) are:\n")
for i in 1 ... n
{
    if(n%i==0)
    {
        print("\(i) " )
    }

}

Result:


0 comments:

Post a Comment