Sublime Number in JavaIn this section, we will learn what is a sublime number and also create Java programs to check if the given number is a sublime number or not. The sublime number program is frequently asked in Java coding interviews and academics. Sublime NumberA natural number N is called sublime number if both the sum of its divisors and the number of its divisors or factors (including itself) are perfect numbers (the number whose sum of factors is equal to the number itself). It is an OEIS sequence A081357. There are only two sublime numbers i.e. 12 that is the smallest sublime number and the second sublime number is 76 digits long number i.e. 6,086,555,670,238,378,989,670,371,734,243,169,622,657,830,773,351,885,970,528,324,860,512,791,691,264. Let's understand it through an example. Sublime Number ExampleLet's see how 12 is a sublime number. The number of factors or divisors of 12 are 6 i.e. 1, 2, 3, 4, 6, and 12 The sum of divisors is: 1 + 2 + 3 + 4 + 6 + 12 = 28 Both 6 and 28 are perfect numbers. Hence, 12 is a sublime number. Steps to Find Sublime Number
Therefore, we have to implement two main logics: 1. Find and Count Divisors of a Number Logic 2. Perfect Number Logic Let's implement the above logic in a Java program and check whether the given number is sublime or not. Subline Number Java ProgramSublimeNumberExample.java Output 1: Enter the number: 12 12 is a sublime number. Output 2: Enter the number: 346587 346587 is not a sublime number. Next TopicAdvanced Java Viva Questions |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India