text: Tcefrep Numbers | C ++ implementation to check if N is a Tcefrep number ; Iterative function to reverse digits of num ; Function to calculate sum of all proper divisors num -- > given natural number ; Final result of summation of divisors ; find all divisors which divides ' num ' ; if ' i ' is divisor of ' num ' ; if both divisors are same then add it only once else add both ; Add 1 to the result as 1 is also a divisor ; Driver Code ; Given Number N ; Function Call
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; int reverse ( int num ) { int rev_num = 0 ; while ( num > 0 ) { rev_num = rev_num * 10 + num % 10 ; num = num / 10 ; } return rev_num ; } int properDivSum ( int num ) { int result = 0 ; for ( int i = 2 ; i <= sqrt ( num ) ; i ++ ) { if ( num % i == 0 ) { if ( i == ( num / i ) ) result += i ; else result += ( i + num / i ) ; } } return ( result + 1 ) ; } bool isTcefrep ( int n ) { return properDivSum ( n ) == reverse ( n ) ; } int main ( ) { int N = 6 ; if ( isTcefrep ( N ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }