
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Program to find multiple of n with only two digits in Python
Suppose we have a number n. We have to find the least positive value x such that x is made up of only two digits 9's and 0's, and x is multiple of n.
So, if the input is like n = 26, then the output will be 90090.
To solve this, we will follow these steps −
- m := 9
- x := 1
- while m is not divisible by n, do
- x := x + 1
- m := replace all 1s with 9s in the binary form of x
- return m as integer
Example
Let us see the following implementation to get better understanding −
def solve(n): m = 9 x = 1 while m % n != 0: x += 1 m = int(bin(x)[2:].replace('1','9')) return m n = 26 print(solve(n))
Input
26
Output
90090
- Related Articles
- Program to find last two digits of 2^n in C++
- Program to Find Out Integers Less than n Containing Multiple Similar Digits in C++
- Program to find minimum digits sum of deleted digits in Python
- Program to find nearest number of n where all digits are odd in python
- How to match only non-digits in Python using Regular \nExpression?\n
- Program to count number of stepping numbers of n digits in python
- Program to find number of substrings with only 1s using Python
- Find n-th element in a series with only 2 digits (and 7) allowed in C++
- Print numbers with digits 0 and 1 only such that their sum is N in C Program.
- Program to find sum of digits in base K using Python
- Program to find last two digits of Nth Fibonacci number in C++
- Program to find number not greater than n where all digits are non-decreasing in python
- Find last two digits of sum of N factorials using C++.
- Python Program to Remove numbers with repeating digits
- Find Numbers with Even Number of Digits in Python

Advertisements