75
Buzz Number Java
Buzz number is another special number in Java that ends with digit 7 or divisible by 7. Unlike Prime and Armstrong numbers, the Buzz number is not so popular and asked by the interviewers.
In simple words, a number is said to be Buzz if it ends with 7 or is divisible by 7.
Let’s take some examples of Buzz numbers.
- 42 is a Buzz number because it is divisible by 7.
- 107 is a Buzz number because it ends with 7.
- 147 is a Buzz number because it ends with 7 and also divisible by 7.
- 134 is not a Buzz number because it is neither end with 7 nor divisible by 7.
These are the following steps that we use to check whether the given number is a Buzz number or not.
- We first take a number.
- We then find the last digit of the number and check whether it is equals to 7 or not. If it equals 7, print “the number is a Buzz” number.
- We then find the remainder of the number with 7. If the remainder equal to 0, print “the number is a Buzz number”.
- Else print “number is not a buzz number”.
Let’s implement a program to check whether the user entered number is a Buzz number or not.
BuzzNumberExample.java
Output
Let’s implement one more program to get all the Buzz number in a given range
FindAllBuzzNumbers.java
Output
Next TopicDuck Number Java