## Moran Numbers in JavaIn this tutorial, we will be discussing ## Example 1:
## Example 2:
## Example 3:
## Validation For the Moran NumberObserve the following algorithm.
- If the sum of the digit is not the factor, we can say that the number n is not the Moran number.
- If the sum of the digit is the factor, then we check whether the answer that comes after dividing the number by the digits sum of the number is a prime number or not.
- If the number that comes after the division is a prime number, then the given input number is a Moran number; otherwise, not.
## ImplementationObserve the implementation of the above algorithm.
The number 45 is a Moran number. The number 36 is not a Moran number. The number 22 is not a Moran number. ## Finding Moran Numbers Within A RangeIn this approach, we will be using a sieve to find the moran numbers within the given range. We are using the sieve because we do not want to use a loop for doing the validation for a prime number. The rest of the other stuff remains the same as the above-written approach. Observe the program.
The Moran numbers that lie within the range 1 to 200 are: 18 21 27 42 45 63 84 111 114 117 133 152 153 156 171 190 195 198 |

For Videos Join Our Youtube Channel: Join Now

- Send your Feedback to [email protected]