Determine whether the given integer N is a Peculiar Number or not | Java implementation to check if the number is peculiar ; Function to find sum of digits of a number ; Function to check if number is peculiar ; Store a duplicate of n ; Driver code
import java . io . * ; class GFG { static int sumDig ( int n ) { int s = 0 ; while ( n != 0 ) { s = s + ( n % 10 ) ; n = n / 10 ; } return s ; } static boolean Pec ( int n ) { int dup = n ; int dig = sumDig ( n ) ; if ( dig * 3 == dup ) return true ; else return false ; } public static void main ( String [ ] args ) { int n = 36 ; if ( Pec ( n ) == true ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }