Insolite Numbers | Java implementation for the above approach ; Function to check if a number is an Insolite numbers ; To store sum of squares of digits ; To store product of squares of digits ; extracting digit ; Driver Code ; Function Call
class GFG { static boolean isInsolite ( int n ) { int N = n ; int sum = 0 ; int product = 1 ; while ( n != 0 ) { int r = n % 10 ; sum = sum + r * r ; product = product * r * r ; n = n / 10 ; } return ( N % sum == 0 ) && ( N % product == 0 ) ; } public static void main ( String [ ] args ) { int N = 111 ; if ( isInsolite ( N ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }