Home » Buzz Number Java

Buzz Number Java

by Online Tutorials Library

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.

  1. 42 is a Buzz number because it is divisible by 7.
  2. 107 is a Buzz number because it ends with 7.
  3. 147 is a Buzz number because it ends with 7 and also divisible by 7.
  4. 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.

  1. We first take a number.
  2. 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.
  3. We then find the remainder of the number with 7. If the remainder equal to 0, print “the number is a Buzz number”.
  4. 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

Buzz Number Java

Let’s implement one more program to get all the Buzz number in a given range

FindAllBuzzNumbers.java

Output

Buzz Number Java


Next TopicDuck Number Java

You may also like