Given a number . The task is to print the multiples of the unit digit of N from the unit digit of N to N.
Note: If the unit digit is 0 then print the multiples of 10.
Input : 39 Output : 9 18 27 36 Explanation : The unit digit of 39 is 9. So the multiples of 9 between 9 and 39 are: 9, 18, 27, 36 Input : 25 Output : 5 10 15 20 25
- Find the unit digit of the input number. Unit digit of N will be (N%10), i.e. remainder upon dividing N by 10.
- Check if the unit digit is 0.
- If yes then consider the multiple as 10.
- Print the multiples of unit digit until it is less than or equal to the input number.
Below is the implementation of the above approach:
# Python3 program to print multiples
# of Unit Digit of Given Number
# Function to print the multiples
# of unit digit
# Find the unit digit of
# the given number
unit_digit = n % 10
# if the unit digit is 0 then
# change it to 10
if (unit_digit == 0):
unit_digit = 10
# print the multiples of unit digit
# until the multiple is less than
# or equal to n
for i in range(unit_digit, n + 1,
print(i, end = ” “)
# Driver Code
n = 39
# This code is contributed by Mohit Kumar
9 18 27 36
- Count numbers with unit digit k in given range
- Perform n steps to convert every digit of a number in the format [count][digit]
- Count of Numbers in Range where first digit is equal to last digit of the number
- Generate a number such that the frequency of each digit is digit times the frequency in given number
- Python Program to print digit pattern
- Special two digit number
- Least Greater number with same digit sum
- First digit in factorial of a number
- Find the frequency of a digit in a number
- Program to delete Nth digit of a Number
- Largest K digit number divisible by X
- Finding sum of digits of a number until sum becomes single digit
- C++ Program for Smallest K digit number divisible by X
- C++ Program for Largest K digit number divisible by X
- Check if the product of digit sum and its reverse equals the number or not
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.