Program 1
A Dudeney number is a positive integer that is a perfect cube such that the sum of its digits is equal to the cube
root of the number. Write a program to input a number and check and print whether it is a Dudeney number or
not.
Example:
Consider the number 512.
Sum of digits = 5 + 1 + 2 = 8
Cube root of 512 = 8
As Sum of digits = Cube root of Number hence 512 is a Dudeney number.
Program 2
A tech number has even number of digits. If the number is split in two equal halves, then the square of sum of
these halves is equal to the number itself. Write a program to generate and print all four digits tech numbers.
Example:
Consider the number 3025
Square of sum of the halves of 3025 = (30 + 25)2
= (55)2
= 3025 is a tech number.
Program 3
Write a program to input a number and count the number of digits. The program further checks whether the
number contains odd number of digits or even number of digits.
Sample Input: 749
Sample Output: Number of digits=3
The number contains odd number of digits.
Program 4
The Greatest Common Divisor (GCD) of two integers is calculated by the continued division method. Divide
the larger number by the smaller, the remainder then divides the previous divisor. The process repeats unless the
remainder reaches to zero. The last divisor results in GCD.
Sample Input: 45, 20
Sample Output: GCD=5
Program 5
Write a program to input a number and check and print whether it is a Pronic number or not. [Pronic number is
the number which is the product of two consecutive integers.]
Examples:
12 = 3 * 4
20 = 4 * 5
42 = 6 * 7
Program 6
Harshad/ Niven Number : is an integer that is divisible by the sum of its digits.
For Example :-
The number 18 is a Harshad number in base 10, because the sum of the digits 1 and 8 is 9 (1 + 8 = 9),
and 18 is divisible by 9 (since 18 % 9 = 0)
The number 1729 is a Harshad number in base 10, because the sum of the digits 1 ,7, 2 and 9 is 19 (1 + 7
+ 2 + 9 = 19), and 1729 is divisible by 19 (1729 = 19 * 91)
The number 19 is not a Harshad number in base 10, because the sum of the digits 1 and 9 is 10 (1 + 9 =
10), and 19 is not divisible by 10 (since 19 % 10 = 9)
The first few Harshad numbers in base 10 are:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20, 21, 24, 27, 30, 36, 40, 42, 45, 48, 50, 54, 60, 63, 70, 72, 80, 81, 84, 90,
100, 102, 108, 110, 111, 112, 114, 117, 120, 126, 132, 133, 135, 140, 144, 150, 152, 153, 156, 162, 171, 180,
190, 192, 195, 198, 200 etc
Program 7
Smith Number : A Smith number is a composite number, the sum of whose digits is the sum of the digits of its
prime factors obtained as a result of prime factorisation (excluding 1). The first few such numbers are 4, 22, 27,
58, 85, 94, 121 ………………..
Examples:
1. 666
Prime factors are 2, 3, 3, and 37
Sum of the digits are (6+6+6) = 18
Sum of the digits of the factors (2+3+3+(3+7)) = 18
2. 4937775
Prime factors are 3, 5, 5, 65837
Sum of the digits are (4+9+3+7+7+7+5) = 42
Sum of the digits of the factors (3+5+5+(6+5+8+3+7)) = 42
Program 8
The International Standard Book Number (ISBN) : is a unique numeric book identifier which is printed on
every book. The ISBN is based upon a 10-digit code. The ISBN is legal if:
1xdigit1 + 2xdigit2 + 3xdigit3 + 4xdigit4 + 5xdigit5 + 6xdigit6 + 7xdigit7 + 8xdigit8 + 9xdigit9 + 10xdigit10 is
divisible by 11.
Example: For an ISBN 1401601499
Sum=1×1 + 2×4 + 3×0 + 4×1 + 5×6 + 6×0 + 7×1 + 8×4 + 9×9 + 10×9 = 253 which is divisible by 11.
Program 9
Happy Number : If a number is happy, then all members of its sequence are happy; if a number is unhappy, all
members of the sequence are unhappy.
For example, 19 is happy, as the associated sequence is:
12 + 92 = 82
82 + 22 = 68
62 + 82 = 100
12 + 02 + 02 = 1.
The 143 happy numbers up to 1,000 are:
1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100, 103, 109, 129, 130, 133, 139, 167,
176, 188, 190, 192, 193, 203, 208, 219, 226, 230, 236, 239, 262, 263, 280, 291, 293, 301, 302, 310, 313, 319,
320, 326, 329, 331, 338, 356, 362, 365, 367, 368, 376, 379, 383, 386, 391, 392, 397, 404, 409, 440, 446, 464,
469, 478, 487, 490, 496, 536, 556, 563, 565, 566, 608, 617, 622, 623, 632, 635, 637, 638, 644, 649, 653, 655,
656, 665, 671, 673, 680, 683, 694, 700, 709, 716, 736, 739, 748, 761, 763, 784, 790, 793, 802, 806, 818, 820,
833, 836, 847, 860, 863, 874, 881, 888, 899, 901, 904, 907, 910, 912, 913, 921, 923, 931, 932, 937, 940, 946,
964, 970, 973, 989, 998, 1000.
The happiness of a number is unaffected by rearranging the digits, and by inserting or removing any number of
zeros anywhere in the number.
Program 10
Write a program to input a number and display the new number after reversing the digits of the original number.
The program also displays the absolute difference between the original number and the reversed number.
Sample Input: 194
Sample Output: 491
Absolute Difference= 297
Program 11
Write a menu driven class to accept a number from the user and check whether it is a Palindrome or a Perfect
number.
(a) Palindrome number: (A number is a Palindrome which when read in reverse order is same as in the right
order)
Example: 11, 101, 151 etc.
(b) Perfect number: (A number is called Perfect if it is equal to the sum of its factors other than the number
itself.)
Example: 6 = 1 + 2 + 3
Program 12
An Abundant number is a number for which the sum of its proper factors is greater than the number itself. Write
a program to input a number and check and print whether it is an Abundant number or not.
Example:
Consider the number 12.
Factors of 12 = 1, 2, 3, 4, 6 Sum of factors = 1 + 2 + 3 + 4 + 6 = 16
As 16 > 12 so 12 is an Abundant number.
Program 13
Special Number : A number is said to be special number when the sum of factorial of its digits is equal to the
number itself.
Program 14
Duck number : A Duck number is a number which has zeroes present in it, but there should be no zero present
in the beginning of the number.
For example : 3210, 7056, 8430709 are all duck numbers whereas 08237, 04309 are not.