# Java Number Programs (ISC Classes 11 / 12)

## Java Iterative Stmts

Write a Program in Java to input a number and check whether it is a Fascinating Number or not.

Fascinating Numbers: Some numbers of 3 digits or more exhibit a very interesting property. The property is such that, when the number is multiplied by 2 and 3, and both these products are concatenated with the original number, all digits from 1 to 9 are present exactly once, regardless of the number of zeroes.

Let's understand the concept of Fascinating Number through the following example:

Consider the number 192

192 x 1 = 192

192 x 2 = 384

192 x 3 = 576

Concatenating the results: 192 384 576

It could be observed that '192384576' consists of all digits from 1 to 9 exactly once. Hence, it could be concluded that 192 is a Fascinating Number. Some examples of fascinating Numbers are: 192, 219, 273, 327, 1902, 1920, 2019 etc.View Answer33 Likes

## Java Iterative Stmts

A number is said to Bouncy number if the digits of the number are unsorted.

For example,

22344 - It is not a Bouncy number because the digits are sorted in ascending order.

774410 - It is not a Bouncy number because the digits are sorted in descending order.

155349 - It is a Bouncy number because the digits are unsorted.

A number below 100 can never be a Bouncy number.Write a program in java to accept a number. Check and display whether it is a Bouncy number or not.

View Answer7 Likes

## Java Iterative Stmts

An Evil number is a positive whole number which has even number of 1's in its binary equivalent. Example: Binary equivalent of 9 is 1001, which contains even number of 1's. A few evil numbers are 3, 5, 6, 9…. Design a program to accept a positive whole number and find the binary equivalent of the number and count the number of 1's in it and display whether it is a Evil number or not with an appropriate message. Output the result in format given below:

Example 1

Input: 15

Binary Equivalent: 1111

No. of 1's: 4

Output: Evil NumberExample 2

Input: 26

Binary Equivalent: 11010

No. of 1's: 3

Output: Not an Evil NumberView Answer10 Likes

## Java Iterative Stmts

A triangular number is formed by the addition of consecutive integers starting with 1. For example,

1 + 2 = 3

1 + 2 + 3 = 6

1 + 2 + 3 + 4 = 10

1 + 2 + 3 + 4 + 5 = 15

Thus, 3, 6, 10, 15, are triangular numbers.

Write a program in Java to display all the triangular numbers from 3 to n, taking the value of n as an input.View Answer10 Likes

## Java Iterative Stmts

A Smith number is a composite number, whose sum of the digits is equal to the sum of its prime factors. For example:

4, 22, 27, 58, 85, 94, 121 ………. are Smith numbers.Write a program in Java to enter a number and check whether it is a Smith number or not.

Sample Input: 666

Sum of the digits: 6 + 6 + 6 = 18

Prime factors are: 2, 3, 3, 37

Sum of the digits of the prime factors: 2 + 3 + 3 + (3 + 7) = 18

Thus, 666 is a Smith Number.View Answer5 Likes

## Java Iterative Stmts

A unique-digit integer is a positive integer (without leading zeros) with no duplicates digits. For example 7, 135, 214 are all unique-digit integers whereas 33, 3121, 300 are not. Given two positive integers m and n, where m < n, write a program to determine how many unique-digit integers are there in the range between m and n (both inclusive) and output them. The input contains two positive integers m and n. Assume m < 30000 and n < 30000. You are to output the number of unique-digit integers in the specified range along with their values in the format specified below:

Sample Input:

m = 100

n = 120

Sample Output:

The Unique-Digit integers are:

102, 103, 104, 105, 106, 107, 108, 109, 120.

Frequency of unique-digit integers is : 9Sample Input:

m = 2500

n = 2550

Sample Output:

The Unique-Digit integers are:

2501, 2503, 2504, 2506, 2507, 2508, 2509, 2510, 2513, 2514, 2516, 2517, 2518, 2517, 2530, 2519, 2530, 2531, 2534, 2536, 2537, 2538, 2539, 2540, 2541, 2543, 2546, 2547, 2548, 2549.

Frequency of unique-digit integers is: 28.View Answer11 Likes

## Java Iterative Stmts

A Composite Magic number is a positive integer which is composite as well as a magic number.

Composite number: A composite number is a number which has more than two factors.

For example:

Factors of 10 are: 1, 2, 5, 10Magic number: A Magic number is a number in which the eventual sum of the digit is equal to 1.

For example: 28 = 2+8=10= 1+0=1Accept two positive integers 'm' and 'n', where m is less than n. Display the number of composite magic integers that are in the range between m and n (both inclusive) and output them along with frequency, in the format specified below:

Sample Input:

m=10 n=100

Output: The composite magic numbers are 10,28,46,55,64,82,91,100

Frequency of composite magic numbers: 8Sample Input:

m=120 n=90

Output: Invalid inputView Answer7 Likes

## User Defined Methods

A Goldbach number is a positive even integer that can be expressed as the sum of two odd primes.

Note: All even integer numbers greater than 4 are Goldbach numbers.

Example:

6 = 3 + 3

10 = 3 + 7

10 = 5 + 5Hence, 6 has one odd prime pair 3 and 3. Similarly, 10 has two odd prime pairs, i.e. 3 and 7, 5 and 5.

Write a program to accept an even integer 'N' where N > 9 and N < 50. Find all the odd prime pairs whose sum is equal to the number 'N'.

Test your program with the following data and some random data:

Example 1

INPUT:

N = 14OUTPUT:

PRIME PAIRS ARE:

3, 11

7, 7Example 2

INPUT:

N = 30OUTPUT:

PRIME PAIRS ARE:

7, 23

11, 19

13, 17Example 3

INPUT:

N = 17OUTPUT:

INVALID INPUT. NUMBER IS ODD.Example 4

INPUT:

N = 126OUTPUT:

INVALID INPUT. NUMBER OUT OF RANGE.View Answer4 Likes

## User Defined Methods

Write a program to input a number. Use a function int Armstrong(int n) to accept the number. The function returns 1, if the number is Armstrong, otherwise zero(0).

Sample Input: 153

Sample Output: 153 ⇒ 1^{3}+ 5^{3}+ 3^{3}= 153

It is an Armstrong Number.View Answer67 Likes

## Java Iterative Stmts

Palindrome Number in Java: Write a program to accept a number from the user and check whether it is a Palindrome number or not. A number is a Palindrome which when reads in reverse order is same as in the right order.

Sample Input: 242

Sample Output: A Palindrome numberSample Input: 467

Sample Output: Not a Palindrome numberView Answer32 Likes

Showing 1 - 10 of 29 Questions