✅ [Solution] Swift: Smallest Integer Divisible by K (+ test cases)
swift\nclass Solution {\n    func smallestRepunitDivByK(_ k: Int) -> Int {\n        guard !(k % 2 == 0 || k % 5 == 0) else { return -1 }\n        guard k != 1 e
```swift\nclass Solution {\n    func smallestRepunitDivByK(_ k: Int) -> Int {\n        guard !(k % 2 == 0 || k % 5 == 0) else { return -1 }\n        guard k != 1 else { return 1 }\n        var length = 1\n        var temp = 1\n        while temp != 0 {\n            temp = (temp * 10 + 1) % k\n            length += 1\n        }\n        return length\n    }\n}\n```\n\n---\n\n<details>\n<summary>\n<img src="https://git.io/JDblm" height="24">\n<b>TEST CASES</b>\n</summary>\n\n<pre>\n<b>Result:</b> Executed 3 tests, with 0 failures (0 unexpected) in 0.008 (0.009) seconds\n</pre>\n\n```swift\nimport XCTest\n\nclass Tests: XCTestCase {\n    \n    private let solution = Solution()\n    \n    func test0() {\n        let value = solution.smallestRepunitDivByK(1)\n        XCTAssertEqual(value, 1)\n    }\n    func test1() {\n        let value = solution.smallestRepunitDivByK(2)\n        XCTAssertEqual(value, -1)\n    }\n    func test3() {\n        let value = solution.smallestRepunitDivByK(3)\n        XCTAssertEqual(value, 3)\n    }\n}\n```\n</details>
['Swift']