Skip to content

Practice Smallest Integer Divisible by K

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1015
LeetCode Problem

Smallest Integer Divisible by K

Problem Statement

Given a positive integer k, you need to find the length of the smallest positive integer n such that n is divisible by k, and n only contains the digit 1. Return the length of n. If there is no such n, return -1. Note: n may not fit in a 64-bit signed integer.

Source: Smallest Integer Divisible by K on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
k = 1
Output
1

# Example 2

Input
k = 2
Output
-1

# Example 3

Input
k = 3
Output
3

Constraints

1 <= k <= 10^5

Related LeetCode Problems

Practice more problems similar to Smallest Integer Divisible by K.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.