Posts

Showing posts from May, 2023

Strong Number in Java

Image
Definition of Strong Number in Java A strong number is a special number that can be defined as an addition of factorial of each digit of the number, which is equal to the number itself. To better understand the concept of a strong number, have a look at the below example.  The number 145 is a strong number. This is because if we add the factorials of each digit of this number, you will get the number, which is 145 itself, as the sum.  1! + 4! + 5! = 1 + 24 + 120 = 145. Logic for Checking Strong Number Take a user-defined number or a number as an input from the user. Store this number in a user-defined variable. Now copy this number to another temporary user-defined variable. This variable will be used for calculation purposes. You can name the user-defined variable as ‘n’ and the temporary variable as ‘temp_n’. Now initialize another variable that will store the sum of factorial digits. You can name this variable as ‘total’. You will also need to find the last digit of th...