Count number of triplets ( a , b , c ) from first N natural numbers such that a * b + c = N | Function to find the count of triplets ( a , b , c ) with a * b + c = N ; Stores count of triplets of 1 st N natural numbers which are of the form a * b + c = N ; Iterate over the range [ 1 , N ] ; If N is divisible by i ; Update cntTriplet ; Update cntTriplet ; Driver code
def findCntTriplet ( N ) : NEW_LINE INDENT cntTriplet = 0 ; NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT if ( N % i != 0 ) : NEW_LINE INDENT cntTriplet += N // i ; NEW_LINE DEDENT else : NEW_LINE INDENT cntTriplet += ( N // i ) - 1 ; NEW_LINE DEDENT DEDENT return cntTriplet ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 3 ; NEW_LINE print ( findCntTriplet ( N ) ) ; NEW_LINE DEDENT