Count divisors which generates same Quotient and Remainder | Python3 program of the above approach ; Function to calculate the count of numbers such that it gives same quotient and remainder ; Stores divisor of number N . ; Iterate through numbers from 2 to sqrt ( N ) and store divisors of N ; As N is also divisor of itself ; Iterate through divisors ; Checking whether x satisfies the required condition ; Print the count ; Driver Code ; Given N ; Function Call
from math import floor , sqrt NEW_LINE def countDivisors ( n ) : NEW_LINE INDENT count = 0 NEW_LINE divisor = [ ] NEW_LINE for i in range ( 2 , floor ( sqrt ( n ) ) ) : NEW_LINE INDENT if ( n % i == 0 ) : NEW_LINE INDENT if ( n // i == i ) : NEW_LINE INDENT divisor . append ( i ) NEW_LINE DEDENT else : NEW_LINE INDENT divisor . append ( i ) NEW_LINE divisor . append ( n // i ) NEW_LINE DEDENT DEDENT DEDENT divisor . append ( n ) NEW_LINE for x in divisor : NEW_LINE INDENT x -= 1 NEW_LINE if ( ( n // x ) == ( n % x ) ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT print ( count ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 1000000000000 NEW_LINE countDivisors ( N ) NEW_LINE DEDENT