Happy Number | method return true if n is Happy Number numSquareSum method is given in below detailed code snippet
static int isHappyNumber ( int n ) { HashSet < Integer > st = new HashSet < > ( ) ; while ( 1 ) { n = numSquareSum ( n ) ; if ( n == 1 ) return true ; if ( st . contains ( n ) ) return false ; st . add ( n ) ; } }