1. Buzz Number: It is a number that is divisible by 7 or it’s last digit is 7.(For example 49 is divisible by 7 so it is a buzz number, 27 has 7 as it’s last digit so it is also a buzz number)

import java. io.*;

class buzz_num
{
public static void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println(“Give a number”);
int num=Integer.parseInt(br.readLine());
int rem;
rem=num%10;
{
if(rem==7 || num%7==0)
System.out.println(“This is a buzz number”);
else
System.out.println(“This is not a buzz number”);
}
}
}

I/p:- 47

O/p:-This is a buzz number.

I/p:- 22

O/p:- This is not a buzz number.

2. Armstrong number:-It is  a  number whose digits cubes sum is equal to the number(for example 153–> (1)3+(5)3+(3)3=1+125+27=153, so it is an Armstrong number)

import java.io.*;
class armstrong
{
public static void main()throws IOException
{
BufferedReader br=new BufferedReader (new InputStreamReader(System.in));
System.out.println(“Give a number”);
int num=Integer.parseInt(br.readLine());
double rem;
int n=num;
int sum=0;
do
{
rem=num%10;
rem=(Math.pow(rem,3));
sum+=rem;
num=num/10;
}while(num!=0);
if(sum==n)
System.out.println(“This is an Armstrong number”);
else
System.out.println(“This is not an Armstrong number”);
}
}

I/p:- 135

O/p:-This is an Armstrong number.

I/p:- 123

O/p:- This is not an Armstrong number.

 

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here