👇👇👇👇👇👍 ALL CODES ARE HERE INCLUDING THE CODES TO FIND SEVERAL NUMBERS WHICH ARE ACTUALLY VERY COMMONLY COMES IN SCHOOL EXAMS AND EVEN IN COMPETITIVE EXAMS ALSO
SO GAIN THE KNOWLEDGE CORRECTLY👍💻🖳🖥🖧
**ALL CODES ARE THOROUGHLY CHECKED AND WE ASSURE YOU THAT IT IS 100% ERROR FREE**
**CODES ARE CONTRIBUTED BY PARARDHA DHAR**
1. Even and odd nos
import java.util.*;
/* Java Program to check whether entered number is EVEN or ODD */
public class j6_ParardhaDhar {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int num;
//input
System.out.print("Enter an integer number: ");
num = sc.nextInt();
//check EVEN or ODD
if (num % 2 == 0) {
System.out.println(num + " is an EVEN number.");
} else {
System.out.println(num + " is an ODD number.");
}
}
}
2. Amstrong No
public class Armstrong {
public static void main(String[] args) {
int low = 999, high = 99999;
for(int number = low + 1; number < high; ++number) {
int digits = 0;
int result = 0;
int originalNumber = number;
// number of digits calculation
while (originalNumber != 0) {
originalNumber /= 10;
++digits;☝
}
originalNumber = number;
// result contains sum of nth power of its digits
while (originalNumber != 0) {
int remainder = originalNumber % 10;
result += Math.pow(remainder, digits);
originalNumber /= 10;
}
if (result == number)
System.out.print(number + " ");
}
}
}
3.Reversed Number
//Java program to Reverse a Number.
import java.util.*;
public class ReverseNumber{
public static void main(String []args){
int number;
Scanner sc=new Scanner(System.in);
//Read Number
System.out.print("Enter an integer number: ");
number=sc.nextInt();
//calculate reverse number
int reverse_number=0;
while(number>0)
{
reverse_number = (reverse_number*10) + number%10;
number/=10;
}
System.out.println("Reverse Number is: " + reverse_number);
}
}
4.Automorphic No
import java.util.Scanner;
public class Automorphic {
public static void main(String args[]){
Scanner in = new Scanner(System.in);
System.out.println("Enter a number");
int num = in.nextInt();
int c=0, sqr = num*num;
int temp =num; //copying num
//countint digits of num
while(temp>0){
c++;
temp=temp/10;
}
int lastSquareDigits = (int) (sqr%(Math.pow(10,c)));
if(num == lastSquareDigits)
System.out.println("Automorphic number");
else
System.out.println("Not an Automorphic number");
}
}
5. HAPPY NO
//WAP to input a numbers and check whether it is happy number or not
import java.util.*;
public class happy_no
{
void main()
{
int a,s=0,r;
Scanner sc=new Scanner(System.in);
System.out.print("Enter any number");
a=sc.nextInt();
do
{
s=0;
while(a>0)
{
r=a%10;
a=a/10;
s=s+r*r;
}
a=s;
}while(a>9);
if(a==1)
{
System.out.print("Happy Number");
}
else
{
System.out.print("Not a Happy Number");
}
}
}
6.KAPREKAR NUMBER
import java.util.*;
public class KaprekarNumbers
{
public static void main(String args[])
{
Scanner ob=new Scanner(System.in);
System.out.println("Enter number");
int n=ob.nextInt();
int N=n*n;
int tn=n;int c=0;
while(tn!=0)
{
tn=tn/10;c++;
}
int q=(int)(N/Math.pow(10,c));
int r=(int)(N%Math.pow(10,c));
if(q+r==n)
System.out.println("Kaprekar number");
else
System.out.println("Non Kaprekar number");
}
}
7.EMRIP NO
import java.util.*;
class Emirp
{public static void main(String args[])
{int m,a,t=0,c=0,ct=0;
Scanner s=new Scanner(System.in);
System.out.println("Enter a no for Emirp test");
int n=s.nextInt();
m=n;
while(n>0)
{ a=n%10;
t=t*10+a;
n=n/10;
}
for(int i=1;i<=m;i++)
{if(m%i==0)
c++;
}
for(int i=1;i<=t;i++)
{if(t%i==0)
ct++;}
if(c==2&&ct==2)
System.out.println("emirp no");
else
System.out.println("not");
}}
8. Odius
import java.util.*;
class odious
{
void main()
{
Scanner ob=new Scanner(System.in);
int n,c=0,d;
System.out.println("Enter a no");
n=ob.nextInt();
while(n!=0)
{
d=n%2;
if(d==1)
{
c++;
}
n=n/2;
}
if(c%2!=0)
{System.out.println("yes");
} else
{
System.out.println("no");
}
}
}
9. Pal-Prime
import java.util.*;
public class palprime
{
void main()
{
int a,s=0,r,c=0,i;
Scanner sc=new Scanner(System.in);
System.out.print("Enter any number: ");
a=sc.nextInt();
for(i=a;i>0;i=i/10)
{
r=i%10;
s=s*10+r;
}
for(i=1;i<a;i++)
{
if(a%i==0)
c++;
}
if(c==2 && a==s)
System.out.print("Pel Prime Number");
else
System.out.print("Not a Pel Prime Number");
}
}
10. ZIPPO NO**
import java.util.*;
class zippo_no
{
void main()
{
Scanner ob=new Scanner(System.in);
int n,m,ld,c=0,d=0,f=0,i,fd;
System.out.println("enter a no");
n=ob.nextInt();
m=n;
ld=n%10;
for(i=n;i!=0;i=i/10)
{
c++;
}
if(c>=3)
{
for(i=n;i!=0;i=i/10)
{
d=i%10;
if(d==0)
f++;
}
fd=d;
if(fd!=0&&ld!=0&&f==(c-2))
System.out.println(n+"is a zippo no");
else
System.out.println(n+"is not a three digit zippo no");
}
}
}
11. CO PRIME NOS
import java.util.*;
public class CoPrime
{
public static void main(String []args)
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the first no");
int no1=sc.nextInt();
System.out.println("Enter the second no");
int no2=sc.nextInt();
int temp;
if(no2>no1)
{
temp=no2;
no2=no1;
no1=temp;
}
int r=-1;
while(r!=0)
{
r=no1%no2;
no1=no2;
no2=r;
}
if(no1==1)
{
System.out.println("CO Prime Number");
}
else
{
System.out.println("Not a CO Prime Number");
}
}
}
12.TWIN PRIME NOS BY USING UNDER CERTAIN RANGE INPUT ED BY THE USER
import java.util.*;
class twin_prime_range
{
void main()
{
Scanner ob=new Scanner(System.in);
int x,y,m,n,i,j,k,c,f;
System.out.println("enter the start range and end range");
x=ob.nextInt();
y=ob.nextInt();
for(i=x;i<=(y-2);i++)
{
m=i;
n=i+2;
c=0;
f=0;
for(j=1;j<=m;j++)
{
if(m%j==0)
{
c++;
}
}
for(k=1;k<=n;k++)
{
if(m%k==0)
{
f++;
}
}
if(c==2 && f==2)
System.out.println(i+","+(i+2));
}
}
}
13.Java program for Palindrome Number - check whether Number is Palindrome or Not.
Check Palindrome Number Example in Java - This program will read an integer number and check whether given number is Palindrome or Not, In this program we will check that number is equal to reverse number than number is palindrome.
//Java program for Palindrome Number.
import java.util.*;
public class Palindrome
{
public static void main(String args[]){
int num,tNum,sum;
Scanner bf=new Scanner(System.in);
//input an integer number
System.out.print("Enter any integer number: ");
num= bf.nextInt();
//find reverse number
tNum=num;
sum =0;
while(tNum>0)
{
sum = (sum*10) + (tNum%10);
tNum/=10;
}
//check inputted number with reversed number
if(num==sum)
System.out.println(num + " is a Palindrome Number.");
else
System.out.println(num + " is not a Palindrome Number.");
}
}
14. Adam NO
import java.util.*;
class Adam_parardha{
public static void main(String args[]){
Scanner in=new Scanner(System.in);
int n=in.nextInt(),m=0,r,s=0,f=0,b=0,a;
double d=Math.pow(n,2);
m=n;
r=m%10; // reverse the input
s=r;
m=m/10;
f=(int)d; // reverse the square
a=f%10;
b=a;
f=f/10;
double e=Math.pow(s,2); // square of input
int k=(int)e;
if(k==b){
System.out.print(n+" is an Adam Number");
}
else{
System.out.print(n+" is NOT an Adam Number");
}
}
}
15. AMICABLE- PAIR
import java.util.Scanner;
public class amicable_pair
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Input the first number: ");
int num1 = in.nextInt();
System.out.print("Input the second number: ");
int num2 = in.nextInt();
int sum_num1 = 0, sum_num2 = 0;
for (int i = 1; i <= num1; i++) {
if (num1 % i == 0)
sum_num1 += i;
}
for (int i = 1; i <= num2; i++) {
if (num2 % i == 0)
sum_num2 += i;
}
if (sum_num1 == sum_num2)
System.out.println("These numbers are amicable.");
else
System.out.println("These numbers are not amicable.");
System.out.println("\n");
}
}
16. GEOMETRIC CENTER OF A NUMBER
import java.util.*;
public class geometric_centre
{
void main()
{
Scanner sc=new Scanner(System.in);
int a,i,b,f=0,s1,s2,j;
System.out.print("Enter any No:");
a=sc.nextInt();
for(i=1;i<=a;i++)
{
s1=0;
s2=0;
for(j=1;j<i;j++)
s1+=j;
for(j=i+1;j<=a;j++)
s2+=j;
if(s1==s2)
{
f=1;
System.out.println("GC: "+i);
}
}
if(f==0)
System.out.println("No GC");
}
}
17. MAGIC NO
import java.util.*;
class MagicNumber
{
void main()
{
int n, r = 1, num, sum = 0;
Scanner sc = new Scanner(System.in);
System.out.print("Enter number=");
n = sc.nextInt();
num = n;
while (num > 9)
{
while (num > 0)
{
r = num % 10;
sum = sum + r;
num = num / 10;
}
num = sum;
sum = 0;
}
if (num == 1)
{
System.out.println("Magic Number");
}
else
{
System.out.println("Not Magic Number");
}
}
}
18. MULTIPLE HARSHAD NO
A Multiple Harshad number is an integer which when divided by the sum of its digits, produces another Harshad number.
For example, consider the number 6804.
6 + 8 + 0 + 4 = 18.
6804 / 18 = 378
3 + 7 + 8 = 18
1 + 8 = 9.
18 / 9 = 2.
So, 6804 is a Multiple Harshad numbers.
import java.util.*;
class multiple_harshadno
{
void main()
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter a number : ");
int n = sc.nextInt();
int c, d, sum = 0,sum1=0,n1=0,count=0;
while(n>1)
{
c=n;sum=0;
while(c>0)
{
d = c%10;
sum = sum + d;
c = c/10;
}
if(n%sum==0)
{
sum1=sum;
n1=n;
n=n/sum;
}
else
{
System.out.println("Not an harshad");
break;
}
}
if(n1%sum1==0)
System.out.println("Number is multiple harshad");
else
System.out.println("Number is not multiple harshad");
}
}
19.NIVEN NUMBER
import java.util.Scanner;
public class NivenNumber
{
public static void main(String[] args)
{
// TODO code application logic here
int n, num, r,
sum = 0;
Scanner sc = new Scanner(System.in);
System.out.print("Enter number=");
n = sc.nextInt();
num = n;
while (num > 0)
{
r = num % 10;
sum = sum + r;
num = num / 10;
}
if (n % sum == 0)
{
System.out.println("Niven Number");
}
else
{
System.out.println("Not Niven Number");
}
}
}
20. PRONIC NUMBER
import java.util.Scanner;
public class Example13 {
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Input a number : ");
int num = sc.nextInt();
int ans = 0;
for(int i=0; i<num; i++)
{
if(i*(i+1) == num)
{
ans = 1;
break;
}
}
if(ans == 1)
System.out.println("Pronic Number.");
else
System.out.println("Not a Pronic Number.");
}
}
21. SPECIAL NO
**EVERYDAY WE ARE CONSTANTLY UPDATING OUR SITE WITH MORE STUFFS AND PROGRAMS TO HELP YOU OUT AND MAKE YOU UNDERSTAND VERY CORRECTLY**
***MORE PROGRAMS COMING ON THE WAY**
**BEFORE COPYING PLEASE APPROACH TO AN IDE AND TRY BY YOURSELF**
**DOUBTS ARE APPRECIATED**
**HAVE SUGGESTIONS GIVE IT IN THE COMMENT**
** WANNA CHECK YOUR PROGRAM HERE POST IT IN THE COMMENT SECTION"
**AGENTS AND TEACHERS ARE ALWAYS ONLINE TO HELP YOU AND MAKE YOU CORRECT**
**AGENTS AND TEACHERS ARE ALWAYS ONLINE TO HELP YOU AND MAKE YOU CORRECT**
**EVERY QUESTIONS WILL BE SOLVED WITHIN NEXT 24HRS**
**THANKS FOR SUPPORTING US**
**NOTE**
*THIS IS A ABSOLUTELY FREE SITE WITH NO ADS TO DISTURB YOU AND YOUR MINDSET****
**TO GIVE YOU FREELY THE CODING FOR JAVA**
**AND WE MAKE SURE TO HELP YOU TO SCORE OUT THE BEST MARKS IN COMPUTER SCIENCE**
**ESPECIALLY MADE FOR SCHOOL STUDENTS**
- import java.util.Scanner;
- public class SpecialNumberExample1
- {
- public static void main(String args[])
- {
- int num, number, last_digit, sum_Of_Fact = 0;
- Scanner sc = new Scanner(System.in);
- System.out.print("Enter a number: ");
- number = sc.nextInt();
- num = number;
- while (number > 0)
- {
- last_digit = number % 10;
- int fact=1;
- for(int i=1; i<=last_digit; i++)
- {
- fact=fact*i;
- }
- sum_Of_Fact = sum_Of_Fact + fact;
- number = number / 10;
- }
- if(num==sum_Of_Fact)
- {
- System.out.println(num+ " is a special number.");
- }
- else
- {
- System.out.println(num+ " is not a special number.");
- }
- }
- }