human
Stella Octangula Number | Returns value of n * ( 2 * n * n - 1 ).
Finds if a value of f ( n ) is equal to x where n is in interval [ low . . high ].
Returns true if x isStella octangula number . Else returns false ..
Find ' high ' for binary search by repeated doubling.
If condition is satisfied for a power of 2..
Call binary search.
Driver code"
How can the above be solved in Python?

=====
Give me a code to stella Octangula Number and the other steps required?
assistant
#Here is code to stella Octangula Number and the other steps required.
 def f ( n ) :
	return n * ( 2 * n * n - 1 ) ;
def binarySearch ( low , high , x ) :
	while ( low <= high ) :
		mid = int ( ( low + high ) // 2 ) ;
		if ( f ( mid ) < x ) :
			low = mid + 1 ;
		elif ( f ( mid ) > x ) :
			high = mid - 1 ;
		else :
			return True ;
	return False ;
def isStellaOctangula ( x ) :
	if ( x == 0 ) :
		return True ;
	i = 1 ;
	while ( f ( i ) < x ) :
		i = i * 2 ;
	if ( f ( i ) == x ) :
		return True ;
	return binarySearch ( i / 2 , i , x ) ;
n = 51 ;
if ( isStellaOctangula ( n ) == True ) :
	print ( " Yes " ) ;
else :
	print ( " No " ) ;