We start from upperbound and find where pi ( i ) - pi ( i / 2 ) < n the previous number being the nth ramanujan prime
for i in range ( upperbound , - 1 , - 1 ) : NEW_LINE INDENT if ( pi ( i , v ) - pi ( i / 2 , v ) < n ) : NEW_LINE INDENT return 1 + i NEW_LINE DEDENT DEDENT