[7719 views]

A number is said to be a buzz number when if it ends with 7 or is divisible by 7. For example: 27, 49,157,63, etc.

Let us consider the number 1007:

1007 is a buzz number as it ends with 7.

Let us consider the number 56:

56 does not end with 7, but it is divisible by 7. Hence it is a buzz number.

In this article, we will learn about the algorithm and flowchart to check whether a given number is buzz number or not.

In this problem, we need to check whether a given number is a buzz number or not. To check this, we need to check whether the number ends with 7 or is divisible by 7. If either of the two conditions is true, the number will be a buzz number.

The algorithm starts off by taking the number to checked as user input, the value is then stored in a variable, say ‘n’. We now find out whether the number ends with 7 or not. To check that, we extract the last digit of the number by doing: d = n % 10. The result is stored in the variable ‘d’. We now find out whether this is divisible by 7. To do this checking, we use the modulus operator. The checking is done by: l = n % 7. The result is stored in the variable ‘l’. Now, if d is equal to 7( which means the number ends with 7) or l is equal to 0( which means the number is divisible by 7), then the given number is a buzz number. If this checking returns true, we display “buzz number”, else, we display “Not a buzz number”.

Note: Here ‘%’ is the modulus operator which returns the remainder value after division.

Let us consider an example:

Let n = 1257

d = 1257 % 10

d = 7

Hence, 1257 is a buzz number.

Let us consider another example:

Let n = 217

l = 217 % 7

l = 0

Hence, 217 is a buzz number.

Use Below Search to get Best Discounts Online

- Algorithm to Count number of Words in Sentence for Beginners
- Algorithm and Flowchart to check if number is Niven number or not
- Algorithm and Flowchart to check whether a number is a spy number or not
- Prefix to Postfix Notation Algorithm and Flowchart
- Flowchart and Algorithm to Replace Lower Case to Upper Case in a String or Sentence