Problem Set 6(Reverse Adam number)

Reverseadam number
A number ‘n’ is said to be a Reverseadam number if the number is divisible by its reverse. A number x is divisible by y if we get zero as the remainder when y divides x. For example, 1221 is a reverseadam number since 1221 is divisible by the reverse of 1221. Reverse of a number is the number got by writing the digits of the number from the rightmost position to the left. Reverse of 14 is 41.
Write an Algorithm and the subsequent Python code to check whether the given number is a Reverseadam number or not.
Write a function to reverse a number

Input Format:
The first line will contain the number.

Output Format:
Print Reverseadam number or Not a reverseadam number

Input:
the number

Processing Involved:
def reverse(n):
    return int(str(abs(n))[::-1])

Output:
display if the number is a reverseadam number or not

Program:
def reverse(n):
    return int(str(n)[::-1])

n = int(input())
if n % reverse(n)==0:
    print('Reverseadam number')
else:
    print('Not a reverseadam number')

Algorithm:
Step1. define the function reverse with one parameter n
Step1.1 return the reverse of the number using string operations
Step2. get the number n
Step3. check if the remainder obtained when n is divided by reverse of n is zero if true then display reverseadam number else display not a reverseadam number
Step4. End

No comments:

Post a Comment

Bonus Practice Problems(GMT To IST)

IST (Indian Standard Time) is 5 hours 30 minutes ahead of GMT(Greenwich Mean Time). Develop an algorithm and write the Python code to find...