This function checks validity of kaprekar ' s ▁ constant . ▁ It ▁ returns ▁ kaprekar ' s constant for any four digit number " n " such that all digits of n are not same .
int kaprekarRec ( int n , int & prev ) { if ( n == 0 ) return 0 ;