# Check whether the given number is buzz number or not

A buzz number is a number that either ends with the digit 7 or is divisible by 7. To check whether a given number is a buzz number or not, follow these steps:

1. Check if the last digit of the number is 7. If yes, then the number is a buzz number.

2. If the last digit of the number is not 7, then check if the number is divisible by 7. To check if a number is divisible by 7, you can use the following rule:

• Take the last digit of the number, double it, and subtract it from the remaining digits.
• If the result is divisible by 7, then the original number is also divisible by 7.
3. If the number is divisible by 7, then it is a buzz number. If not, then it is not a buzz number.

## Program Solution

``````// C program for
// Check whether the given number is buzz number or not
#include <stdio.h>

void isBuzzNo(int number)
{
if (number % 7 == 0 || number % 10 == 7)
{
// When last digit is 7
// or number is divisible by 7
printf(" Number %d is buzz number\n", number);
}
else
{
printf(" Number %d is not buzz number\n", number);
}
}
int main(int argc, char
const *argv[])
{
// Test Cases
isBuzzNo(126);
isBuzzNo(123);
isBuzzNo(2120);
isBuzzNo(107);
isBuzzNo(170);
return 0;
}``````

#### input

`````` Number 126 is buzz number
Number 123 is not buzz number
Number 2120 is not buzz number
Number 107 is buzz number
Number 170 is not buzz number``````
``````/*
Java Program for
Check whether the given number is buzz number or not
*/
public class BuzzNumber
{
public void isBuzzNo(int number)
{
if (number % 7 == 0 || number % 10 == 7)
{
// When last digit is 7
// or number is divisible by 7
System.out.println(" Number " + number + " is buzz number");
}
else
{
System.out.println(" Number " + number + " is not buzz number");
}
}
public static void main(String[] args)
{
// Test Cases
}
}``````

#### input

`````` Number 126 is buzz number
Number 123 is not buzz number
Number 2120 is not buzz number
Number 107 is buzz number
Number 170 is not buzz number``````
``````// Include header file
#include <iostream>

using namespace std;
/*
C++ Program for
Check whether the given number is buzz number or not
*/
class BuzzNumber
{
public: void isBuzzNo(int number)
{
if (number % 7 == 0 || number % 10 == 7)
{
// When last digit is 7
// or number is divisible by 7
cout << " Number " << number << " is buzz number" << endl;
}
else
{
cout << " Number " << number << " is not buzz number" << endl;
}
}
};
int main()
{
// Test Cases
return 0;
}``````

#### input

`````` Number 126 is buzz number
Number 123 is not buzz number
Number 2120 is not buzz number
Number 107 is buzz number
Number 170 is not buzz number``````
``````// Include namespace system
using System;
/*
Csharp Program for
Check whether the given number is buzz number or not
*/
public class BuzzNumber
{
public void isBuzzNo(int number)
{
if (number % 7 == 0 || number % 10 == 7)
{
// When last digit is 7
// or number is divisible by 7
Console.WriteLine(" Number " + number + " is buzz number");
}
else
{
Console.WriteLine(" Number " + number + " is not buzz number");
}
}
public static void Main(String[] args)
{
// Test Cases
}
}``````

#### input

`````` Number 126 is buzz number
Number 123 is not buzz number
Number 2120 is not buzz number
Number 107 is buzz number
Number 170 is not buzz number``````
``````<?php
/*
Php Program for
Check whether the given number is buzz number or not
*/
class BuzzNumber
{
public	function isBuzzNo(\$number)
{
if (\$number % 7 == 0 || \$number % 10 == 7)
{
// When last digit is 7
// or number is divisible by 7
echo " Number ".\$number.
" is buzz number".
"\n";
}
else
{
echo " Number ".\$number.
" is not buzz number".
"\n";
}
}
}

function main()
{
// Test Cases
}
main();``````

#### input

`````` Number 126 is buzz number
Number 123 is not buzz number
Number 2120 is not buzz number
Number 107 is buzz number
Number 170 is not buzz number``````
``````/*
Node JS Program for
Check whether the given number is buzz number or not
*/
class BuzzNumber
{
isBuzzNo(number)
{
if (number % 7 == 0 || number % 10 == 7)
{
// When last digit is 7
// or number is divisible by 7
console.log(" Number " + number + " is buzz number");
}
else
{
console.log(" Number " + number + " is not buzz number");
}
}
}

function main()
{
// Test Cases
}
main();``````

#### input

`````` Number 126 is buzz number
Number 123 is not buzz number
Number 2120 is not buzz number
Number 107 is buzz number
Number 170 is not buzz number``````
``````#  Python 3 Program for
#  Check whether the given number is buzz number or not
class BuzzNumber :
def isBuzzNo(self, number) :
if (number % 7 == 0 or number % 10 == 7) :
#  When last digit is 7
#  or number is divisible by 7
print(" Number", number ,"is buzz number")
else :
print(" Number", number ,"is not buzz number")

def main() :
#  Test Cases

if __name__ == "__main__": main()``````

#### input

`````` Number 126 is buzz number
Number 123 is not buzz number
Number 2120 is not buzz number
Number 107 is buzz number
Number 170 is not buzz number``````
``````#  Ruby Program for
#  Check whether the given number is buzz number or not
class BuzzNumber
def isBuzzNo(number)
if (number % 7 == 0 || number % 10 == 7)
#  When last digit is 7
#  or number is divisible by 7
print(" Number ", number ," is buzz number", "\n")
else
print(" Number ", number ," is not buzz number", "\n")
end

end

end

def main()
#  Test Cases
end

main()``````

#### input

`````` Number 126 is buzz number
Number 123 is not buzz number
Number 2120 is not buzz number
Number 107 is buzz number
Number 170 is not buzz number
``````
``````/*
Scala Program for
Check whether the given number is buzz number or not
*/
class BuzzNumber()
{
def isBuzzNo(number: Int): Unit = {
if (number % 7 == 0 || number % 10 == 7)
{
// When last digit is 7
// or number is divisible by 7
println(" Number " + number + " is buzz number");
}
else
{
println(" Number " + number + " is not buzz number");
}
}
}
object Main
{
def main(args: Array[String]): Unit = {
var task: BuzzNumber = new BuzzNumber();
// Test Cases
}
}``````

#### input

`````` Number 126 is buzz number
Number 123 is not buzz number
Number 2120 is not buzz number
Number 107 is buzz number
Number 170 is not buzz number``````
``````/*
Swift 4 Program for
Check whether the given number is buzz number or not
*/
class BuzzNumber
{
func isBuzzNo(_ number: Int)
{
if (number % 7 == 0 || number % 10 == 7)
{
// When last digit is 7
// or number is divisible by 7
print(" Number", number ,"is buzz number");
}
else
{
print(" Number", number ,"is not buzz number");
}
}
}
func main()
{
// Test Cases
}
main();``````

#### input

`````` Number 126 is buzz number
Number 123 is not buzz number
Number 2120 is not buzz number
Number 107 is buzz number
Number 170 is not buzz number``````
``````/*
Kotlin Program for
Check whether the given number is buzz number or not
*/
class BuzzNumber
{
fun isBuzzNo(number: Int): Unit
{
if (number % 7 == 0 || number % 10 == 7)
{
// When last digit is 7
// or number is divisible by 7
println(" Number " + number + " is buzz number");
}
else
{
println(" Number " + number + " is not buzz number");
}
}
}
fun main(args: Array < String > ): Unit
{
// Test Cases
}``````

#### input

`````` Number 126 is buzz number
Number 123 is not buzz number
Number 2120 is not buzz number
Number 107 is buzz number
Number 170 is not buzz number``````

## Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.