human
Find Prime Adam integers in the given range [ L , R ] | Python3 program to find all prime adam numbers in the given range.
Reversing a number by taking remainder at a time.
Function to check if a number is a prime or not.
Iterating till the number.
Checking for factors.
Returning 1 if the there are no factors of the number other than 1 or itself.
Function to check whether a number is an adam number or not.
Reversing given number.
Squaring given number.
Squaring reversed number.
Reversing the square of the reversed number.
Checking if the square of the number and the square of its reverse are equal or not.
Function to find all the prime adam numbers in the given range.
If the first number is greater than the second number , print invalid.
Iterating through all the numbers in the given range.
Checking for prime number.
Checking for Adam number.
Driver code"
Solution in Python:
 ... Can you provide a code to find Prime Adam integers in the given range [ L , R ] and the other steps required?
assistant
#Here is code to find Prime Adam integers in the given range [ L , R ] and the other steps required.
 def reverse ( a ) :
	rev = 0 ;
	while ( a != 0 ) :
		r = a % 10 ;
		rev = rev * 10 + r ;
		a = a // 10 ;
	return ( rev ) ;
def prime ( a ) :
	k = 0 ;
	for i in range ( 2 , a ) :
		if ( a % i == 0 ) :
			k = 1 ;
			break ;
	if ( k == 1 ) :
		return ( 0 ) ;
	else :
		return ( 1 ) ;
def adam ( a ) :
	r1 = reverse ( a ) ;
	s1 = a * a ;
	s2 = r1 * r1 ;
	r2 = reverse ( s2 ) ;
	if ( s1 == r2 ) :
		return ( 1 ) ;
	else :
		return ( 0 ) ;
def find ( m , n ) :
	if ( m > n ) :
		print ( " INVALID INPUT " ) ;
	else :
		c = 0 ;
	for i in range ( m , n ) :
		l = prime ( i ) ;
		k = adam ( i ) ;
		if ( ( l == 1 ) and ( k == 1 ) ) :
			print ( i , " 	 " , end = " ▁ " ) ;
L = 5 ; R = 100 ;
find ( L , R ) ;