
Problem
Solution
Submissions
Check if a Number is a Multiple of Another
Certification: Basic Level
Accuracy: 74.6%
Submissions: 126
Points: 5
Write a Python program that checks if a number is a multiple of another number.
Example 1
- Input: number = 15, divisor = 5
- Output: True
- Explanation:
- Step 1: Check if number is divisible by divisor (15 % 5 == 0).
- Step 2: Since the remainder is 0, 15 is divisible by 5.
- Step 3: Return True.
Example 2
- Input: number = 17, divisor = 3
- Output: False
- Explanation:
- Step 1: Check if number is divisible by divisor (17 % 3 == 0).
- Step 2: Since the remainder is 2, 17 is not divisible by 3.
- Step 3: Return False.
Constraints
- -10^9 ≤ number ≤ 10^9
- -10^9 ≤ divisor ≤ 10^9, divisor ≠ 0
- Time Complexity: O(1)
- Space Complexity: O(1)
Editorial
My Submissions
All Solutions
Lang | Status | Date | Code |
---|---|---|---|
You do not have any submissions for this problem. |
User | Lang | Status | Date | Code |
---|---|---|---|---|
No submissions found. |
Solution Hints
- Use modulo operator: number % divisor == 0
- Create a function: def is_multiple(num, div): return num % div == 0
- Use lambda function: is_multiple = lambda num, div: num % div == 0
- For zero edge case: if divisor == 0: raise ZeroDivisionError("Divisor cannot be zero")