Iterate through all values of S and check the mentioned condition
for i in range ( 2 , S + 1 ) : NEW_LINE INDENT d = i NEW_LINE if ( ( S / d ) >= pow ( P , 1.0 / d ) ) : NEW_LINE INDENT return i NEW_LINE DEDENT DEDENT