1.
Factorial Calculation: Write a Java program to calculate the factorial of a given
number using a for loop. Prompt the user to enter a positive integer and then display
its factorial.
2. Prime Factorization: Create a Java program that finds and prints all the prime factors
of a given number. Use a for loop to iterate through numbers and check if they are
factors and prime.
3. Sum of Factors: Write a Java program that calculates and prints the sum of all the
factors of a given integer. For example, for input 12, the program should display 28
(1 + 2 + 3 + 4 + 6 + 12).
4. Perfect Number: A perfect number is a positive integer that is equal to the sum of its
proper divisors (excluding itself). Write a Java program that checks if a given number
is a perfect number and displays the result.
5. Abundant Number: An abundant number is a positive integer for which the sum of
its proper divisors is greater than the number itself. Create a Java program that
determines whether a given number is abundant or not. Display the result
accordingly.
6. Amicable Numbers: Write a Java program to find and print all pairs of amicable
numbers within a given range. Amicable numbers are two numbers such that the
sum of the proper divisors of each number is equal to the other number.
7. Common Factors: Create a Java program that takes two positive integers as input
and finds and prints the common factors (divisors) of both numbers using a for loop.
8. GCD (Greatest Common Divisor): Implement a Java program to find and display the
greatest common divisor (GCD) of two positive integers using a for loop and the
Euclidean algorithm.
9. LCM (Least Common Multiple): Write a Java program that calculates and prints the
least common multiple (LCM) of two positive integers using a for loop and the
formula LCM(a, b) = (a * b) / GCD(a, b), where GCD is the greatest common divisor.
10. Triangular Numbers: A triangular number is the sum of natural numbers up to a
certain number. Write a Java program to print the first n triangular numbers, where
n is given as input. For example, if n is 5, the program should display 1, 3, 6, 10, and
15 (the first 5 triangular numbers).
11. Factorial Series Sum: Write a Java program to calculate and print the sum of the
series 1! + 2! + 3! + ... + n!, where n is a positive integer provided as input.
12. Perfect Number Range: Create a Java program that finds and prints all perfect
numbers within a given range. Allow the user to input the range (start and end).
13. Armstrong Numbers: An Armstrong number (also known as a narcissistic number) is
a number that is equal to the sum of its own digits raised to the power of the
number of digits. Write a Java program to check and print all Armstrong numbers
within a given range.
14. Harshad Numbers: A Harshad number (Niven number) is an integer that is divisible
by the sum of its digits. Implement a Java program to find and display all Harshad
numbers within a specified range.
15. Factorial Prime: Write a Java program that calculates and prints the factorial of a
given number, but only if the factorial is a prime number. If the factorial is not prime,
display a message indicating so.
16. Palindromic Factors: Create a Java program that takes an integer as input and finds
and prints all the palindromic factors of that number. Palindromic factors are factors
that are palindromes (e.g., 121, 22, 11).
17. Triangular Number Check: Write a Java program that checks if a given positive
integer is a triangular number or not. A triangular number is one that can be
expressed as the sum of consecutive natural numbers (e.g., 10 is a triangular number
because 1 + 2 + 3 + 4 = 10).
18. Perfect Square Factors: Implement a Java program that takes an integer as input and
finds and prints all the perfect square factors of that number. Perfect square factors
are factors that are perfect squares (e.g., 4, 9, 16).
19. Pronic Numbers: A pronic number, also known as a rectangular number, is the
product of two consecutive integers. Write a Java program to find and display all
pronic numbers within a specified range.
20. Harshad Number Sum: Create a Java program that calculates and prints the sum of
all Harshad numbers (Niven numbers) within a given range.
21. Fibonacci Series: Write a Java program to generate and print the Fibonacci series up
to a specified number of terms.
22. Arithmetic Progression (AP): Implement a Java program that calculates and prints
the first n terms of an arithmetic progression (AP) with a given common difference
and starting value.
23. Geometric Progression (GP): Create a Java program to calculate and print the first n
terms of a geometric progression (GP) with a given common ratio and starting value.
24. Square Numbers: Write a Java program that generates and prints the first n square
numbers, where n is provided as input.
25. Prime Numbers Series: Implement a Java program that generates and prints the first
n prime numbers, where n is provided as input.
26. Triangular Numbers Series: Create a Java program to generate and print the first n
triangular numbers, where n is specified by the user.
27. Harmonic Series: Write a Java program to calculate and print the sum of the
harmonic series up to a specified number of terms.
28. Lucas Numbers Series: Implement a Java program to generate and print the first n
Lucas numbers, where n is provided as input.
29. Squares of Odd Numbers: Create a Java program to generate and print the squares
of the first n odd natural numbers, where n is specified by the user.
30. Collatz Sequence: Write a Java program that generates and prints the Collatz
sequence for a given starting number, stopping when the sequence reaches 1.