Skip to main content

Numbers Programming Exercise | Java Programming ( ISC ) | Level 2

 Numbers Programming Exercise


Questions :

1.     Write a Java program to print all the possible Abundant numbers (integers) between M and N (1 > M, N < 100000).

In number theory, an abundant number is a number for which the sum of its proper divisors is greater than the number itself.

The first few abundant numbers are:
12, 18, 20, 24, 30, 36, 40, 42, 48, 54, 56, 60, 66, 70, 72, 78, 80, 84, 88, 90, 96, 100, 102,…

The integer 12 is the first abundant number. Its proper divisors are 1, 2, 3, 4 and 6 for a total of 16.

👉 View Solution (1)


2.     Write a Java program to display first N Lucas numbers. ( 3>N>100 )
The Lucas numbers or series are integer sequences named after the mathematician François Édouard Anatole Lucas, who studied both that sequence and the closely related Fibonacci numbers. Lucas numbers and Fibonacci numbers form complementary instances of Lucas sequences.
The sequence of Lucas numbers : 2, 1, 3, 4, 7, 11, 18, 29, ….

    ðŸ‘‰View Solution(1)

 

3.     Write a Java program to find and print the Happy numbers between m and n.
Happy number: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1, or it loops endlessly in a cycle which does not include 1.
Example: 19 is a happy number
12 + 92=82
82 + 22=68
62 + 82=100
12 + 02 + 02=1

The first few happy numbers are 1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100, ...

    ðŸ‘‰View Solution(1)

                                                                    

4.     Write a Java program to check whether a number is an Automorphic number or not.
In mathematics, an automorphic number is a number whose square "ends" in the same digits as the number itself. For example, 52 = 25, 62 = 36, 762 = 5776, and 8906252 = 793212890625, so 5, 6, 76, and 890625 are all automorphic numbers.
Expected Output

Input a number : 76                                                   
76 is an Automorphic Number.
 

5.     Write a Java program to check whether a given number is an Ugly number.
In the number system, ugly numbers are positive numbers whose only prime factors are 2, 3, or 5. The first 10 ugly numbers are 1, 2, 3, 4, 5, 6, 8, 9, 10, 12. By convention, 1 is included.
Test Data :    Enter a positive  number: 235
Expected Output :    It is not an ugly number.

6.     Write a Java program to check whether a given number is a Disarium number or Unhappy number.
A Disarium number is a number defined by the following process :
Sum of its digits powered with their respective position is equal to the original number.
For example, 175 is a Disarium number :
As 11+32+53 = 135
Some other DISARIUM are 89, 175, 518, etc.
A number will be called Disarium if the sum of its digits powered with their respective position is equal to the number itself. Sample Input: 135.

7.     Write a Java program to check whether a number is a Harshad Number or not.
In recreational mathematics, a Harshad number in a given number base is an integer that is divisible by the sum of its digits when written in that base.
Example: Number 200 is a Harshad Number because the sum of digits 2 and 0 and 0 is 2(2+0+0) and 200 is divisible by 2. Number 171 is a Harshad Number because the sum of digits 1 and 7 and 1 is 9(1+7+1) and 171 is divisible by 9.

Input a number : 353                                                    
Expected Output :  353 is not a Harshad Number.
 

8.     Write a Java program to check whether a number is a Duck Number or not.
Note: A Duck number is a number that has zeroes present in it, but there should be no zero present at the beginning of the number. For example 3210, 7056, 8430709 are all duck numbers whereas 08237, 04309 are not.
Expected Output

Input a number : 3210                                                   
Duck number
 

9.     Write a Java program to check two numbers are Amicable numbers or not.
Amicable numbers are two different numbers so related that the sum of the proper divisors of each is equal to the other number.
The first ten amicable pairs are: (220, 284), (1184, 1210), (2620, 2924), (5020, 5564), (6232, 6368), (10744, 10856), (12285, 14595), (17296, 18416), (63020, 76084), and (66928, 66992).
Expected Output

Input the first number: 220                                             
Input the second number: 284                                            
These numbers are amicable.
 

10.    Write a Java program to check whether a number is a Pronic Number or Heteromecic Number or not.
A pronic number is a number that is the product of two consecutive integers, that is, a number of the form n(n + 1).
The first few pronic numbers are:
0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380, 420, 462 … etc.

Comments

Popular posts from this blog

Harshad Number | C programming

  Q.10     WAP in C/ C++/ java to check whether a number is a  Harshad Number  or not.  In recreational mathematics, a Harshad number in a given number base is an integer that is divisible by the sum of its digits when written in that base.         Example: Number 200 is a Harshad Number because the sum of digits 2 and 0 and 0 is 2(2+0+0) and 200 is divisible by 2. Number 171 is a Harshad Number because the sum of digits 1 and 7 and 1 is 9(1+7+1) and 171 is divisible by 9.     Solution :  #include <stdio.h> int   sumofdigits ( int  x)  // function to compute sum of digits {      int   sum = 0 ;      while (x > 0 )     {          sum += x % 10 ;         x = x / 10 ;     }      return   sum ; } void   main () {      int   n ,  sod ;      printf ( " \n Enter any positive number : " );      scanf ( " %d " ,  & n );      if  ( n < 0 )     {          printf ( " \n Invalid input! Enter the value again -->" );          main ();  // calls the m

Happy Number Solution | Recursion

  /**  * Write a Java program to find and print the Happy numbers between m and n. Happy number: Starting with any positive integer, replace the number by the sum of the squares of its digits,  and repeat the process until the number equals 1, or it loops endlessly in a cycle which does not include 1. Example: 19 is a happy number 1^2 + 9^2=82 8^2 + 2^2=68 6^2 + 8^2=100 1^2 + 0^2 + 02=1 The first few happy numbers are 1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100, ...  */ import java.util.*; public class HappyNum {     public static int digitSq( int x) // recursive function to find square of digits of the number     {         if(x<10)         return x*x;         else         return (x%10)*(x%10) + digitSq(x/10);     } // end of digitSq()          public static boolean isHappy(int num, int i)  // recursive function to check whether the no. is happy or not     {         //System.out.println(num);         if(num==1)         return true;         else i