Part of the series

Several example codes

~1 min read • Updated Oct 13, 2025

Program Overview

This Python program reads an integer n and displays all its multiples up to a limit (default 1000) that do not share any digits with n.
It uses string conversion and set operations to compare digits.


Python Code:


def digits_of(num: int) -> set:
    return set(str(num))

def is_digit_disjoint(a: int, b: int) -> bool:
    return digits_of(a).isdisjoint(digits_of(b))

def display_valid_multiples(n: int, limit: int = 1000):
    print(f"Multiples of {n} without shared digits:")
    for i in range(1, limit + 1):
        multiple = n * i
        if is_digit_disjoint(multiple, n):
            print(multiple)

# Read input from user
n = int(input("Enter value for n: "))
display_valid_multiples(n)

Sample Output (input: n = 23):


46  
69  
92  
115  
...  

Written & researched by Dr. Shahin Siami