From 1638ca01acb1bf3149d50866ed1f87db72c6dfdc Mon Sep 17 00:00:00 2001 From: chayan das Date: Tue, 25 Nov 2025 23:48:07 +0530 Subject: [PATCH] Create 1015. Smallest Integer Divisible by K --- 1015. Smallest Integer Divisible by K | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 1015. Smallest Integer Divisible by K diff --git a/1015. Smallest Integer Divisible by K b/1015. Smallest Integer Divisible by K new file mode 100644 index 0000000..ed45207 --- /dev/null +++ b/1015. Smallest Integer Divisible by K @@ -0,0 +1,12 @@ +class Solution { +public: + int smallestRepunitDivByK(int k) { + if (k % 2 == 0 || k % 5 == 0) return -1; + int r = 0; + for (int i = 1; i <= k; i++) { + r = (r * 10 + 1) % k; + if (r == 0) return i; + } + return -1; + } +};