Refactorable number | C ++ program to check whether number is refactorable or not ; Function to count all divisors ; Initialize result ; If divisors are equal , count only one . ; Otherwise count both ; Driver Code
#include <bits/stdc++.h> NEW_LINE bool isRefactorableNumber ( int n ) { int divCount = 0 ; for ( int i = 1 ; i <= sqrt ( n ) ; ++ i ) { if ( n % i == 0 ) { if ( n / i == i ) ++ divCount ; else divCount += 2 ; } } return n % divCount == 0 ; } int main ( ) { int n = 8 ; if ( isRefactorableNumber ( n ) ) puts ( " yes " ) ; else puts ( " no " ) ; n = 14 ; if ( isRefactorableNumber ( n ) ) puts ( " yes " ) ; else puts ( " no " ) ; return 0 ; }