Skip to content

Commit fb6a0d9

Browse files
authored
Add files via upload
1 parent 5348c92 commit fb6a0d9

28 files changed

+783
-0
lines changed

Amicable_Number.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import java.util.*;
2+
class Amicable_Number
3+
{
4+
public static void main(String Args[])
5+
{
6+
Scanner sc=new Scanner(System.in);
7+
System.out.println("Enter a two numbers");
8+
int n1=sc.nextInt();
9+
int n2=sc.nextInt();
10+
int i,s1=0,s2=0;
11+
for(i=1;i<=n1;i++)
12+
{
13+
if(n1%i==0 || n1%i==n1)
14+
s1=s1+i;
15+
}
16+
for(i=1;i<=n2;i++)
17+
{
18+
if(n2%i==0 || n2%i==n2)
19+
s2=s2+i;
20+
}
21+
if(s1==n2 && s2==n1)
22+
23+
System.out.println("Amicable Number");
24+
else
25+
System.out.println("Not an Amicable Number");
26+
}
27+
}

Armstrong_No.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import java.util.*;
2+
class Armstrong_No
3+
{
4+
public static void main(String args[])
5+
{
6+
Scanner sc=new Scanner(System.in);
7+
System.out.println("Enter a number");
8+
int n=sc.nextInt();
9+
int copy=n,s=0;
10+
while(n!=0)
11+
{
12+
int d=n%10;
13+
s=s+(d*d*d);
14+
n=n/10;
15+
}
16+
if(copy==s)
17+
System.out.println("Armstrong Number");
18+
else
19+
System.out.println("Not an Armstrong Number");
20+
}
21+
}

Automorphic_No.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import java.util.Scanner;
2+
public class Automorphic_No
3+
{
4+
public static void main(String args[])
5+
{
6+
Scanner sc = new Scanner(System.in);
7+
System.out.print("Input a number : ");
8+
int num = sc.nextInt();
9+
int sq_num = num*num;
10+
11+
String str_num = Integer.toString(num);
12+
String square = Integer.toString(sq_num);
13+
14+
if(square.endsWith(str_num))
15+
System.out.println("Automorphic Number.");
16+
else
17+
System.out.println("Not an Automorphic Number.");
18+
}
19+
}

Bouncy_23.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import java.io.*;
2+
class Bouncy_23
3+
{
4+
public static void main(String args[])throws IOException{
5+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
6+
System.out.print("N = ");
7+
int n = Integer.parseInt(br.readLine());
8+
if(n < 0){
9+
System.out.println("Not an increasing number.");
10+
System.out.println("Not a decreasing number.");
11+
System.out.println("Not a bouncy number.");
12+
return;
13+
}
14+
if(isIncreasing(n))
15+
System.out.println(n + " is an increasing number.");
16+
if(isDecreasing(n))
17+
System.out.println(n + " is a decreasing number.");
18+
if(!isIncreasing(n) && !isDecreasing(n))
19+
System.out.println(n + " is a bouncy number.");
20+
}
21+
public static boolean isIncreasing(int num){
22+
int last = num % 10;
23+
boolean status = true;
24+
while(num != 0){
25+
int digit = num % 10;
26+
if(digit > last){
27+
status = false;
28+
break;
29+
}
30+
last = digit;
31+
num /= 10;
32+
}
33+
return status;
34+
}
35+
public static boolean isDecreasing(int num){
36+
int last = num % 10;
37+
boolean status = true;
38+
while(num != 0){
39+
int digit = num % 10;
40+
if(digit < last){
41+
status = false;
42+
break;
43+
}
44+
last = digit;
45+
num /= 10;
46+
}
47+
return status;
48+
}
49+
}

Buzz_No.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import java.util.*;
2+
class Buzz_No
3+
{
4+
public static void main(String args[])
5+
{
6+
Scanner sc=new Scanner(System.in);
7+
System.out.println("Enter a number");
8+
int n=sc.nextInt();
9+
if(n%10==7 || n%7==0)
10+
System.out.println("Buzz Number");
11+
else
12+
System.out.println("Not a Buzz Number");
13+
}
14+
}

Composite_No.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import java.util.*;
2+
class Composite_No
3+
{
4+
public static void main(String args[])
5+
{
6+
Scanner sc=new Scanner(System.in);
7+
System.out.println("Enter a number");
8+
int n=sc.nextInt();
9+
int i,c=0;
10+
for(i=1;i<=n;i++)
11+
{
12+
if(n%i==0)
13+
c++;
14+
}
15+
if (c>2)
16+
17+
System.out.println("Composite Number");
18+
else
19+
System.out.println("Not a Composite Number");
20+
}
21+
}
22+

Convert.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import java.util.*;
2+
class Convert
3+
{
4+
static int n,b,oct;
5+
static int a[],a2[];
6+
Convert(int nn)
7+
{
8+
n=nn;
9+
a=new int[n];
10+
a2=new int[n];
11+
b=0;
12+
oct=0;
13+
}
14+
void bin()
15+
{
16+
int x=n;
17+
while(x>0)
18+
{
19+
a[b++]=x%2;
20+
x=x/2;
21+
}
22+
}
23+
void oct()
24+
{
25+
int x=n;
26+
while(x>0)
27+
{
28+
a2[oct++]=x%8;
29+
x=x/8;
30+
}
31+
}
32+
public static void main()
33+
{
34+
Scanner sc= new Scanner(System.in);
35+
System.out.print("Enter number ");
36+
int num=sc.nextInt();
37+
38+
Convert ob=new Convert(num);
39+
ob.bin();
40+
ob.oct();
41+
System.out.print("Binary Number : ");
42+
for(int i=b-1;i>=0;i--)
43+
System.out.print(a[i]);
44+
System.out.print("\nOctal Number : ");
45+
for(int i=oct-1;i>=0;i--)
46+
System.out.print(a2[i]);
47+
48+
}
49+
50+
}

Disarium_No.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.util.*;
2+
public class Disarium_No
3+
{
4+
public static void main(String args[])
5+
{
6+
Scanner sc = new Scanner(System.in);
7+
System.out.print("Input a number : ");
8+
int num = sc.nextInt();
9+
int copy = num, d = 0, sum = 0;
10+
String s = Integer.toString(num);
11+
int len = s.length();
12+
while(copy>0)
13+
{
14+
d = copy % 10;
15+
sum = sum + (int)Math.pow(d,len);
16+
len--;
17+
copy = copy / 10;
18+
}
19+
20+
if(sum == num)
21+
System.out.println("Disarium Number.");
22+
else
23+
System.out.println("Not a Disarium Number.");
24+
}
25+
}

Duck_No.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import java.util.*;
2+
class Duck_No
3+
{
4+
// Function to check whether
5+
// the given number is duck number or not.
6+
static boolean check_duck(String num)
7+
{
8+
// Ignore leading 0s
9+
int i = 0, n = num.length();
10+
while (i < n && num.charAt(i) == '0')
11+
i++;
12+
13+
// Check remaining digits
14+
while (i < n) {
15+
if (num.charAt(i) == '0')
16+
return true;
17+
i++;
18+
}
19+
20+
return false;
21+
}
22+
23+
// Driver Method
24+
public static void main(String args[])
25+
{
26+
String num = "1023";
27+
if (check_duck(num))
28+
System.out.println("It is a duck number");
29+
else
30+
System.out.println("It is not a duck number");
31+
}
32+
}

Emrip_No_21.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import java.util.*;
2+
class Emrip_No_21
3+
{
4+
public static void main(String args[])
5+
{
6+
Scanner sc=new Scanner(System.in);
7+
System.out.println("Enter a number");
8+
int n=sc.nextInt();
9+
int i,c=0,e=0,copy=n,s=0;
10+
for(i=1;i<=n;i++)
11+
{
12+
if(n%i==0)
13+
c++;
14+
}
15+
while(copy!=0)
16+
{
17+
int d=copy%10;
18+
s=((s*10)+d);
19+
copy=copy/10;
20+
}
21+
for(i=1;i<=s;i++)
22+
{
23+
if(s%i==0)
24+
e++;
25+
}
26+
if(c==2 && e==2)
27+
System.out.println("Emrip No");
28+
else
29+
System.out.println("Not an Emrip No");
30+
}
31+
}

Even_or_Odd_3.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import java.util.*;
2+
// A simple Java program
3+
// to check for even or odd
4+
class Even_or_Odd_3
5+
{
6+
// Returns true if n
7+
// is even, else odd
8+
static boolean isEven(int n)
9+
{
10+
// Return true if
11+
// n/2 does not result
12+
// in a float value.
13+
return ((n / 2) * 2 == n);
14+
}
15+
// Driver code
16+
public static void main(String[] args)
17+
{
18+
Scanner sc=new Scanner(System.in);
19+
System.out.println("Enter a number");
20+
int n =sc.nextInt();
21+
if(isEven(n) != false)
22+
System.out.print( "Even" );
23+
else
24+
System.out.print( "Odd" );
25+
}
26+
}

Fibonacci_6_2nd_type.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import java.util.*;
2+
class Fibonacci_6_2nd_type
3+
{
4+
public static void main(String args[])
5+
{
6+
Scanner sc=new Scanner(System.in);
7+
System.out.println("Enter limit number");
8+
int n=sc.nextInt();
9+
int a=0,b=1,c=0,i;
10+
for(i=0;i<=n;i++)
11+
{
12+
System.out.println(a+" ,");
13+
a=a+b;
14+
b=a-b;
15+
}
16+
}
17+
}

Fibonacci_No.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import java.util.*;
2+
class Fibonacci_No
3+
{
4+
public static void main(String args[])
5+
{
6+
Scanner sc=new Scanner(System.in);
7+
System.out.println("Enter limit number");
8+
int n=sc.nextInt();
9+
int a=0,b=1,c=0,i;
10+
for(i=0;i<=n;i++)
11+
{
12+
c=a+b;
13+
System.out.println(a+" ,");
14+
a=b;
15+
b=c;
16+
}
17+
}
18+
}

HCF_LCM_17.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import java.util.*;
2+
class HCF_LCM_17
3+
{
4+
public static void main(String args[])
5+
{
6+
Scanner sc=new Scanner(System.in);
7+
System.out.println("enter two numbers ");
8+
int a=sc.nextInt();
9+
int b=sc.nextInt();
10+
int min=Math.min(a,b);
11+
int h=0;
12+
for(int i=1;i<=min;i++)
13+
{
14+
if(a%i==0 && b%i==0)
15+
h=i;
16+
}
17+
double l=(a*b)/h;
18+
System.out.println("HCF= "+h);
19+
System.out.println("LCM= "+l);
20+
}
21+
}

0 commit comments

Comments
 (0)