- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes

- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages

- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation

- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples

# How To Check Whether a Number Is a Insolite Number or Not in Java?

A number is said to be an Insolite number, if the number is divisible by both addition of squares of each digit and square of the whole product value of all digits.

For more clarification, we have to find the addition of squares of each digit. Then we have to multiply each digit of the given number and after that we have to calculate the square value of it. If the given number is divisible by both the resultant values, then we can say that the given number is an Insolite number.

In this article we will see how to check if a number is Insolite by using Java programming language.

## To show you some instances

### Instance-1

Input number is 1122112.

Let’s check it by using the logic of the Insolite number.

The addition of squares of each digit of 1122112 is =

= (1^2) + (1^2) ++ (2^2) + (2^2) + (1^2) + (1^2) + (2^2) = 1 + 1 + 4 + 4 + 1 + 1 + 4 = 16

The square of the whole production value of all digits of 1122112 =

=(1 * 1 * 2 * 2 * 1 * 1 * 2 ) ^ 2 = 64

1122112 is divisible by both 16 and 64.

Hence, 1122112 is an Insolite number.

### Instance-2

Input number is 123123.

Let’s check it by using the logic of the Insolite number.

The addition of squares of each digit of 123123 is =

=(1^2) + (2^2) ++ (3^2) + (1^2) + (2^2) + (3^2) = 1 + 4 + 9 + 1 + 4 + 9 = 28

The square of the whole production value of all digits of 123123=

=(1 * 2 * 3 * 1 * 2 * 3) ^ 2 = 1296

123123 is not divisible by both 28 and 1296.

Hence, 123123 is not an Insolite number.

### Instance-3

Input number is 121212.

Let’s check it by using the logic of the Insolite number.

The addition of squares of each digit of 121212 is =

= (1^2) + (2^2) ++ (1^2) + (2^2) + (1^2) + (2^2) = 1 + 4 + 1 + 4 + 1 + 4 = 15

The square of the whole production value of all digits of 121212 =

= (1 * 2 * 1 * 2 * 1 * 2) ^ 2 = 64

121212 is not divisible by both 15 and 64.

Hence, 123123 is not an Insolite number.

## Syntax

To get the power of any number raised to the power of another number in Java we have inbuilt **java.lang.Math.pow()** method.

Following is the syntax to get power of 2 by using the method

double power = Math.pow(inputValue,2)

## Algorithm

**Step 1**− Get an integer number either by initialization or by user input.**Step 2**− Then take a loop till the binary number is equal to zero.**Step 3**− Calculate the sum and product of the square of each digit.**Step 4**− Finally, check the condition whether the resultant values are divisible by our input number or not.**Step 5**− If it is divisible then we conclude that the number is an insolite number otherwise the number is not an insolite number.

## Multiple Approaches

We have provided the solution in different approaches.

By Using Static Input Value

By Using User Defined Method

Let’s see the program along with its output one by one.

### Approach-1: By Using Static Input Value

In this approach one integer value will be initialized in the program and then by using the algorithm we can check whether a number is an insolite number or not.

#### Example

import java.util.*; import java.lang.Math; public class Main{ //main method public static void main (String[] args){ //declare a variable with a static input value int inputNumber = 1122112 ; //store the input number into an another variable int temp = inputNumber; // for storing the addition value declare a variable int sum = 0; // for storing the multiplication value declare a variable int prod = 1; //loop to calculate both sum and product value while (temp != 0){ // take digits from unit place int i = temp % 10; //calculate the sum value sum = sum + (int)Math.pow(i, 2); //calculate the multiplication value prod = prod * (int)Math.pow(i, 2); //removing that unit place value temp = temp / 10; } //check the condition //whether both resultant values are divisible by inputNumberor not if((inputNumber % sum == 0) && (inputNumber % prod == 0)) System.out.print(inputNumber + " is an Insolite Number."); else System.out.print(inputNumber + " is not an Insolite Number."); } }

#### Output

1122112 is an Insolite Number.

### Approach-2: By Using User Defined

In this approach the user will be asked to take the input of an integer value and then we will call a user defined method by passing this input number as parameter.

Inside the method we will check whether a number is an insolite number or not by using the algorithm.

#### Example

public class Main{ //main method public static void main (String[] args){ //declare an int variable and initialize a number int inputNumber =126317; System.out.println("Given number: "+inputNumber); //call the user defined method inside conditional statement if (checkInsolite(inputNumber)){ //if its true System.out.println(inputNumber + " is an Insolite Number."); } else { //if its true System.out.println(inputNumber + " is not an Insolite Number."); } } // define the user defined method // check for Insolitenumber static boolean checkInsolite(int inputNumber){ //store the input number into an another variable int temp = inputNumber; // for storing the addition value declare a variable int sum = 0; // for storing the multiplication value declare a variable int prod = 1; //loop to calculate both sum and product value while (temp != 0){ // take digits from unit place int i = temp % 10; //calculate the sum value sum = sum + i * i; //calculate the multiplication value prod = prod * i * i; //removing that unit place value temp = temp / 10; } //check the condition //whether both resultant values are divisible by inputNumberor not if((inputNumber % sum == 0) && (inputNumber % prod == 0)) return true; else return false; } }

#### Output

Given number: 126317 126317 is not an Insolite Number.

In this article, we explored how to check a number whether it is an insolite number or not in Java by using different approaches.

- Related Articles
- How to Check Whether a Number is Krishnamurthy Number or Not in Java?
- How To Check Whether a Number is Strontio Number or Not in Java?
- How To Check Whether a Number is Tcefrep Number or Not in Java?
- How To Check Whether a Number is Tech Number or Not in Java?
- How To Check Whether a Number Is a Pronic Number or Not in Java?
- How To Check Whether a Number Is a Bouncy Number or Not in Java?
- How To Check Whether a Number is a Evil Number or Not in Java?
- How To Check Whether a Number Is a Fascinating Number or Not in Java?
- How To Check Whether a Number is a Harshad Number or Not in Java?
- How To Check Whether a Number is a Keith Number or Not in Java?
- How To Check Whether a Number Is a Niven Number or Not in Java?
- How To Check Whether a Number is a Sunny Number or Not in Java?
- How to Check Whether a Number is a Triangular Number or Not in Java?
- How To Check Whether a Number is a Unique Number or Not in Java?
- How To Check Whether a Number is a Goldbach Number or Not in Java?