Strong Number Check in Java: Explanation & Practice
Check if a number is a strong number
Problem summary
A strong number equals the sum of factorials of its digits (e.g., 145 = 1! + 4! + 5!). Check if the given number is strong.
Starter code
public class Main {
public static void main(String[] args) {
int number = 145; // Test case 1
// Check if strong number
// Print: Is strong: <true/false>
}
}Expected output and test cases
- 145 = 1!+4!+5! = 145
Is strong: true
- 2 = 2! = 2
Is strong: true
- 123 is not strong
Is strong: false
Hints
- Extract each digit
- Calculate factorial of each digit
- Sum factorials and compare with original
Related Core Java Basics exercises
- Practice Triangle Type Checker in Java
- Practice Happy Number Check in Java
- Practice Automorphic Number Check in Java
Practice all Core Java Basics exercises · Run this idea in the Java compiler