#NEWLINE# @ classmethod #NEWLINE# def eval( cls , n , k = 1 ) : #NEWLINE# #INDENT# n = sympify ( n ) #NEWLINE# k = sympify ( k ) #NEWLINE# if n . is_prime : #NEWLINE# #INDENT# return ( 1 + ( n ** k ) ) #NEWLINE# #UNINDENT# if n . is_Integer : #NEWLINE# #INDENT# if ( n <= 0 ) : #NEWLINE# #INDENT# raise ValueError ( 'n must be a positive integer' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return Mul ( * [ ( 1 + ( p ** ( k * e ) ) ) for ( p , e ) in factorint ( n ) . items ( ) ] )