# Untouchable Number in Java

In this section, we will learn what is an untouchable number and also create Java programs to check if the given number is an untouchable number or not. The untouchable number program is frequently asked in Java coding interviews and academics.

## Untouchable Number

A number N is called an untouchable number if the number is not the sum of the proper divisor of any positive number. It is also called nonaliquot numbers. It is an OEIS sequence A005114.

In other words, we can say that it is a positive integer that cannot be expressed as the sum of all the proper divisors of any positive integer including the untouchable number itself.

### Properties

• Any untouchable number is not a perfect number.
• Except for 2 and 5, all untouchable numbers are composite.

Let's understand it through an example.

### Untouchable Number Example

The number 4 is not an untouchable number because it is equal to the sum of the proper divisors of 9 i.e., 1+3 = 4.

The number 5 is an untouchable number because it is not equal to the sum of the proper divisors of any positive number. It means to say that there is only a way to write 5 i.e. 1+4. The number 4 divides a number, also 2 does the same. So, 1+4 cannot be the sum of any proper divisors.

Some other untouchable numbers are 2, 5, 52, 88, 96, 120, 124, 146, 162, 188, 206, 210, 216, 238, 246, 248, 262, 268, 276, 288, 290, 292, 304, 306, 322, 324, 326, 336, 342, 372, 406, 408, 426, 430, 448, 472, 474, 498, 516, 518, 520, 530, 540, 552, 556, 562, 576, 584, 612, 624, 626, 628, 658.

We observe that the number 5 is the only odd untouchable number.

## Steps to Find Untouchable Number

1. Read or initialize a number N.
2. Find all the divisors of the given number N.
3. Check if i is the divisor of N or not:
• If yes, add i to the variable sum.
• Else, add sum, i (divisor), and the resultant of (num/i) together.
• At last, add 1 to the variable sum.
4. Check if the sum of all the proper divisors is equal to the number n, the number is untouchable, else not.

Let's implement the above steps in a Java program.

## Untouchable Number Java Program

In the following program, we find the sum of the proper divisors of the number N and check whether the sum is equal to N or not. If the sum is equal to N, the given number N is an untouchable number. Else, not an untouchable number.

UntouchableNumberExample.java

Output 1:

```Enter the number: 5
The given number is an untouchable number.
```

Output 2:

```Enter the number: 36
The given number is not an untouchable number.
```

### Feedback   