Javatpoint Logo
Javatpoint Logo

Nude Numbers in Java

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

Nude Number

A number is said to be nude number if all the digits of the number is the factor of that number. In short, nude numbers are those numbers that expose their factor.

Example 1:

672 is a nude number because all the digits (6, 7, and 2) of the number are the factors of the number itself.

Let's see another example.

Example 2:

101 is not a nude number because all of the digits of the number 101, i.e., 1 and 0, do not divide the number 101. Observe that 1 divides the number 101, but 0 does not divide the number. Thus, we got at least one digit that does not divide the number 101.

Nude Number Java Program

Iterative Approach

Let's see the implementation to find the nude number using while loop.

FileName: NudeNumbers.java

Output:

Nude numbers between 10 to 60 are:
11 12 15 22 24 33 36 44 48 55

Recursive Approach

We can also achieve the same result using recursion. The following program shows the same.

FileName: NudeNumbers1.java

Output:

Nude numbers from 10 to 60 are:
11 12 15 22 24 33 36 44 48 55

Note: We know that every number is drivable by itself. Therefore, a single-digit number (except 0) is a nude number. For example, 1, 2, 3, …, 9 are nude numbers. Another point to note that a number multiplied by 0 is always 0. Therefore, 0 can never be a factor of any number. Hence, any number that contains 0 can never be a nude number.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA