Given a number N, print all the Strong Numbers less than or equal to N.
Strong number is a special number whose sum of the factorial of digits is equal to the original number.
For Example: 145 is strong number. Since, 1! + 4! + 5! = 145.
Input: N = 100
Output: 1 2
Only 1 and 2 are the strong numbers from 1 to 100 because
1! = 1, and
2! = 2
Input: N = 1000
Output: 1 2 145
Only 1, 2 and 145 are the strong numbers from 1 to 1000 because
1! = 1,
2! = 2, and
(1! + 4! + 5!) = 145
Approach: The idea is to iterate from [1, N] an check if any number between the range is strong number or not. If yes then print the corresponding number, else check for next number.
Below is the implementation of the above approach:
1 2 145
Time Complexity: O(N)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Print all Semi-Prime Numbers less than or equal to N
- Print all Jumping Numbers smaller than or equal to a given value
- Fill the missing numbers in the array of N natural numbers such that arr[i] not equal to i
- Print N lines of 4 numbers such that every pair among 4 numbers has a GCD K
- Check if N is Strong Prime
- Program to check Strong Number
- Print all non-increasing sequences of sum equal to a given number x
- Print all proper fractions with denominators less than equal to N
- Count numbers whose XOR with N is equal to OR with N
- Making three numbers equal with the given operations
- Minimum numbers (smaller than or equal to N) with sum S
- Find all factorial numbers less than or equal to n
- Sum of Semi-Prime Numbers less than or equal to N
- Different ways to sum n using numbers greater than or equal to m
- Split N^2 numbers into N groups of equal sum
- Make all numbers of an array equal
- Split numbers from 1 to N into two equal sum subsets
- Count numbers whose difference with N is equal to XOR with N
- Place N^2 numbers in matrix such that every row has an equal sum
- Count the numbers < N which have equal number of divisors as K