Chapter 1 number-
18. Kaprekar Number – Square split
sums to original number
based programs... Example: 45 → 45²=2025 → 20+25=45
19. Buzz Number – Divisible by 7 or
1. Sum of Digits – Sum of all digits of a number ends with 7
Example: 452 → 4+5+2 = 11
Example: 14, 17 → Buzz Number
2. Reverse a Number – Reverse the digits of a number 20. Spy Number – Sum of digits =
Example: 1234 → 4321 Product of digits
3. Palindrome Number – Check if number reads same Example: 123 → 1+2+3=6 & 1×2×3=6
forward & backward → Spy
Example: 121 → Palindrome, 123 → Not Palindrome
21. Triangular Number – Sum of first n
4. Armstrong Number – Sum of digits raised to the natural numbers = number
power of digits = number
Example: 10 → 1+2+3+4=10
Example: 153 → 1³ + 5³ + 3³ = 153
22. Perfect Square – Number whose
5. Perfect Number – Sum of proper divisors = number square root is an integer
Example: 28 → 1+2+4+7+14 = 28
Example: 16 → √16=4 → Perfect
6. Prime Number – Number divisible only by 1 and Square
itself
23. Perfect Cube – Number whose cube
Example: 13 → Prime, 12 → Not Prime
root is an integer
7. Prime Numbers in Range – Print all primes in a range
Example: 27 → ³√27=3 → Perfect Cube
Example: 1–10 → 2,3,5,7
24. Pronic Number – Product of two
8. Factorial of a Number – Product of all numbers up to consecutive numbers
n
Example: 5! = 1×2×3×4×5 = 120 Example: 6 → 2×3=6
25. Abundant Number – Sum of proper
9. Fibonacci Series – Sequence where next = sum of
divisors > number
previous two
Example: n=5 → 0,1,1,2,3 Example: 12 → 1+2+3+4+6=16 >12 →
Abundant
10. HCF of Two Numbers – Highest common factor
Example: 12 & 18 → HCF = 6 26. Deficient Number – Sum of proper
divisors < number
11. LCM of Two Numbers – Least common multiple
Example: 12 & 18 → LCM = 36 Example: 10 → 1+2+5=8 <10 →
Deficient
12. Automorphic Number – Square ends with the
27. Tech Number – Split number into
number itself
Example: 25 → 25²=625 → Ends with 25 halves, sum halves, square = original
number
13. Neon Number – Sum of digits of square = number
Example: 9 → 9²=81 → 8+1=9 Example: 2025 → 20+25=45 →
45²=2025 → Tech Number
14. Magic Number – Sum of digits repeatedly until single
digit = 1 28. Fascinating Number – Multiply by 2
Example: 19 → 1+9=10 → 1+0=1 → Magic & 3, concatenate with original, digits
1–9 appear once
15. Strong Number – Sum of factorials of digits =
number Example: 192 → 192384576 →
Example: 145 → 1!+4!+5! = 145 Fascinating
16. Harshad (Niven) Number – Number divisible by sum 29. Happy Number – Sum of squares of
of digits digits repeatedly until 1 → Happy
Example: 18 → 1+8=9 → 18%9=0 → Harshad
Example: 19 → 1²+9²=82 → … → 1 →
17. Duck Number – Contains zeros (not starting with Happy
zero)
30. Sad (Unhappy) Number – Does not
❑ Example: 102 → Duck Number, 012 → Not valid
reach 1 in above process → Sad
❑
Example: 4 → 4²=16 → … loops → Sad
1) sum of the digits Scanner sc = new Scanner([Link]);
import [Link]; [Link]("Enter a number: ");
class SumOfDigits { int num = [Link]();
public static void main(String[] args){ int original = num;
Scanner sc = new Scanner([Link]); int reverse = 0;
[Link]("Enter a number: "); while(num != 0){
int num = [Link](); reverse = reverse * 10 + num % 10; // Build reverse
int sum = 0; num /= 10; // Remove last digit
while(num != 0){ }
sum += num % 10; // Get last digit and add to sum if(original == reverse){
num /= 10; // Remove last digit [Link](original + " is a Palindrome number.");
} } else {
[Link]("Sum of digits: " + sum); [Link](original + " is not a Palindrome
number.");
}
}
}
}
2) reversing a no
import [Link]; 3) Armstrong number
class ReverseNumber { import [Link];
public static void main(String[] args){ class ArmstrongNumberEasy {
Scanner sc = new Scanner([Link]); public static void main(String[] args){
[Link]("Enter a number: "); Scanner sc = new Scanner([Link]);
int num = [Link](); [Link]("Enter a number: ");
int reverse = 0; int num = [Link]();
while(num != 0){ int original = num;
reverse = reverse * 10 + num % 10; // Add last digit to int sum = 0;
reverse
while(num > 0){
num /= 10; // Remove last digit
int digit = num % 10; // Get last digit
}
sum += digit * digit * digit; // Cube it and add to sum
[Link]("Reversed number: " + reverse);
num /= 10; // Remove last digit
}
}
}
if(sum == original)
[Link](original +”is an armstrong no” );
3)palindrome
else
import [Link];
[Link](original +”is not an Armstrong no”);
class PalindromeNumber {
}
public static void main(String[] args){
}
temp /= 10; // remove last digit
roblem: A number is perfect if the sum of its factors }
(excluding itself) equals the number.
Example: 6 → Factors = 1, 2, 3 → 1+2+3 = 6 → Perfect }
if(sum == 1)
import [Link];
[Link](n + " is Magic");
class PerfectNumber {
else
public static void main(String[] args){
[Link](n + " is Not Magic");
Scanner sc = new Scanner([Link]);
}
[Link]("Enter a number: ");
}
int num = [Link]();
____________________________________________________
int sum = 0;
for(int i = 1; i < num; i++){
if(num % i == 0) // check factor
sum += i;
if(sum == num)
[Link](num + " is a Perfect number.");
else
[Link](num + " is not a Perfect number.");
****************************************************
4) MAGIC NUMBER…
👉 Idea: Keep adding digits until we get a single digit. If it
becomes 1 → Magic.
import [Link];
class MagicEasy {
public static void main(String[] args){
Scanner sc = new Scanner([Link]);
[Link]("Enter a number: ");
int n = [Link]();
int sum = n;
while(sum > 9){ // repeat till single digit
int temp = sum;
sum = 0;
while(temp > 0){
sum += temp % 10; // add last digit