Master fundamental Java concepts with these beginner-friendly programs
The traditional first program in any programming language that demonstrates basic syntax.
Learn how to perform basic arithmetic operations and variable assignment in Java.
Understand conditional statements and the modulus operator in Java.
A program to compare two numbers and find the larger one using conditional logic.
A program to calculate simple interest using the formula SI = (P × R × T) / 100.
A program to check whether a given year is a leap year.
A program to swap two numbers without using a third variable.
A program to find the factorial of a number.
A program to reverse a given number.
A program to find the sum of digits of a number.
A program to check whether a number is prime or not.
A program to print the multiplication table of a given number.
A program to find the largest of three numbers.
A program to check whether a number is a palindrome.
A program to print the Fibonacci series up to N terms.
A program to check whether a number is an Armstrong number.
Write a program to check whether a number is an Armstrong number.
153
153 is an Armstrong number
num = 153.A program to check whether a number is a Perfect number.
Write a program to check whether a number is a Perfect number (sum of its factors excluding itself equals the number).
28
28 is a Perfect Number
num = 28.A program to check if a number is a Strong number.
Write a program to check if a number is a Strong number (sum of factorials of digits equals the number).
145
145 is a Strong Number
A program to check if a number is Automorphic (its square ends with the number itself).
Write a program to check if a number is Automorphic (its square ends with the number itself).
25
25 is an Automorphic Number
A program to check if a number is a Harshad number (divisible by the sum of its digits).
Write a program to check if a number is a Harshad number (divisible by the sum of its digits).
18
18 is a Harshad Number
A program to check whether a number is a Duck number (contains at least one zero but not at the beginning).
Write a program to check whether a number is a Duck number (contains at least one zero but not at the beginning).
1023
1023 is a Duck Number
A program to check whether a number is a Neon number (sum of digits of square of the number equals the number).
Write a program to check whether a number is a Neon number (sum of digits of square of the number equals the number).
9
9 is a Neon Number
A program to check whether a number is a Kaprekar number (sum of parts of its square equals the number).
Write a program to check whether a number is a Kaprekar number (sum of parts of its square equals the number).
45
45 is a Kaprekar Number
A program to check if a number is a Magic number (repeated sum of digits results in 1).
Write a program to check if a number is a Magic number (sum of digits repeated until a single digit results in 1).
19
19 is a Magic Number
A program to find the HCF (GCD) of two numbers.
Write a program to find the Highest Common Factor (HCF) or Greatest Common Divisor (GCD) of two numbers.
36, 60
HCF of 36 and 60 is 12
Check whether a number is an Automorphic number.
Write a program to check whether a number is an Automorphic number.
76
Automorphic Number
public class AutomorphicNumber {
public static void main(String[] args) {
int num = 76;
int square = num * num;
String numStr = String.valueOf(num);
String squareStr = String.valueOf(square);
if (squareStr.endsWith(numStr)) {
System.out.println("Automorphic Number");
} else {
System.out.println("Not an Automorphic Number");
}
}
}
endsWith() method.Check whether a number is a Peterson number.
Write a program to check whether a number is a Peterson number.
145
Peterson Number
public class PetersonNumber {
public static void main(String[] args) {
int num = 145;
int temp = num;
int sum = 0;
while (temp > 0) {
int digit = temp % 10;
sum += factorial(digit);
temp /= 10;
}
if (sum == num) {
System.out.println("Peterson Number");
} else {
System.out.println("Not a Peterson Number");
}
}
static int factorial(int n) {
int fact = 1;
for (int i = 2; i <= n; i++) {
fact *= i;
}
return fact;
}
}
Check whether a number is a Sunny number.
Write a program to check whether a number is a Sunny number.
80
Sunny Number
public class SunnyNumber {
public static void main(String[] args) {
int num = 80;
int nextNum = num + 1;
double sqrt = Math.sqrt(nextNum);
if (sqrt == (int) sqrt) {
System.out.println("Sunny Number");
} else {
System.out.println("Not a Sunny Number");
}
}
}
Check whether a number is a Fascinating number.
Write a program to check whether a number is a Fascinating number.
192
Fascinating Number
public class FascinatingNumber {
public static void main(String[] args) {
int num = 192;
if (num < 100) {
System.out.println("Not a Fascinating Number");
return;
}
String result = "" + num + (num * 2) + (num * 3);
boolean isFascinating = result.length() == 9;
for (char c = '1'; c <= '9' && isFascinating; c++) {
if (result.indexOf(c) == -1 || result.replace(String.valueOf(c), "").length() != result.length() - 1) {
isFascinating = false;
}
}
if (isFascinating) {
System.out.println("Fascinating Number");
} else {
System.out.println("Not a Fascinating Number");
}
}
}
Check whether a number is a Keith number.
Write a program to check whether a number is a Keith number.
197
Keith Number
import java.util.ArrayList;
public class KeithNumber {
public static void main(String[] args) {
int num = 197;
int temp = num;
ArrayList<Integer> terms = new ArrayList<>();
// Extract digits and add to list
while (temp > 0) {
terms.add(0, temp % 10);
temp /= 10;
}
int n = terms.size();
int sum = 0, i = n;
while (sum < num) {
sum = 0;
for (int j = i - n; j < i; j++) {
sum += terms.get(j);
}
terms.add(sum);
i++;
}
if (sum == num) {
System.out.println("Keith Number");
} else {
System.out.println("Not a Keith Number");
}
}
}
n digits.Check whether a number is a Neon number.
Write a program to check whether a number is a Neon number.
9
Neon Number
public class NeonNumber {
public static void main(String[] args) {
int num = 9;
int square = num * num;
int sum = 0;
while (square > 0) {
sum += square % 10;
square /= 10;
}
if (sum == num) {
System.out.println("Neon Number");
} else {
System.out.println("Not a Neon Number");
}
}
}
Check whether a number is a Spy number.
Write a program to check whether a number is a Spy number.
123
Spy Number
public class SpyNumber {
public static void main(String[] args) {
int num = 123;
int sum = 0, product = 1;
int temp = num;
while (temp > 0) {
int digit = temp % 10;
sum += digit;
product *= digit;
temp /= 10;
}
if (sum == product) {
System.out.println("Spy Number");
} else {
System.out.println("Not a Spy Number");
}
}
}
Simulate basic ATM operations using a menu-driven approach.
Write a Java program to simulate basic ATM operations such as withdraw, deposit, and check balance using a menu-driven approach.
1 (Check Balance), 2 (Withdraw), 3 (Deposit)
Current Balance: 1000
Withdrawn: 500
New Balance: 500
import java.util.Scanner;
public class ATMProgram {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int balance = 1000;
while (true) {
System.out.println("\nATM Menu:");
System.out.println("1. Check Balance");
System.out.println("2. Withdraw");
System.out.println("3. Deposit");
System.out.println("4. Exit");
System.out.print("Choose an option: ");
int choice = scanner.nextInt();
switch (choice) {
case 1:
System.out.println("Current Balance: " + balance);
break;
case 2:
System.out.print("Enter amount to withdraw: ");
int withdraw = scanner.nextInt();
if (withdraw > balance) {
System.out.println("Insufficient Balance.");
} else {
balance -= withdraw;
System.out.println("Withdrawn: " + withdraw);
System.out.println("New Balance: " + balance);
}
break;
case 3:
System.out.print("Enter amount to deposit: ");
int deposit = scanner.nextInt();
balance += deposit;
System.out.println("Deposited: " + deposit);
System.out.println("New Balance: " + balance);
break;
case 4:
System.out.println("Thank you for using the ATM.");
return;
default:
System.out.println("Invalid option.");
}
}
}
}
Check whether a number is an Autobiographical number.
Write a program to check if a number is an Autobiographical number. (Each digit describes how many times digits 0-9 occur in the number.)
1210
Autobiographical Number
public class AutobiographicalNumber {
public static void main(String[] args) {
String num = "1210";
int[] count = new int[10];
// Count digits
for (int i = 0; i < num.length(); i++) {
int digit = num.charAt(i) - '0';
count[digit]++;
}
// Check if each digit matches the frequency
boolean isAutoBio = true;
for (int i = 0; i < num.length(); i++) {
int expected = num.charAt(i) - '0';
if (count[i] != expected) {
isAutoBio = false;
break;
}
}
if (isAutoBio) {
System.out.println("Autobiographical Number");
} else {
System.out.println("Not an Autobiographical Number");
}
}
}
Check whether a number is an Emirp number.
Write a program to check whether a number is an Emirp number or not. (A number is Emirp if it is prime and its reverse is also a different prime.)
13
Emirp Number
public class EmirpNumber {
public static void main(String[] args) {
int num = 13;
if (isPrime(num)) {
int rev = reverseNumber(num);
if (rev != num && isPrime(rev)) {
System.out.println("Emirp Number");
} else {
System.out.println("Not an Emirp Number");
}
} else {
System.out.println("Not an Emirp Number");
}
}
public static boolean isPrime(int n) {
if (n <= 1) return false;
for (int i = 2; i <= Math.sqrt(n); i++) {
if (n % i == 0) return false;
}
return true;
}
public static int reverseNumber(int n) {
int rev = 0;
while (n != 0) {
rev = rev * 10 + n % 10;
n /= 10;
}
return rev;
}
}
Check whether a number is a Sphenic number.
Write a program to check whether a number is a Sphenic number or not. (A number is Sphenic if it is a product of three distinct prime numbers.)
30
Sphenic Number
public class SphenicNumber {
public static void main(String[] args) {
int num = 30;
int count = 0;
int product = 1;
int temp = num;
for (int i = 2; i <= temp && count <= 3; i++) {
if (isPrime(i) && temp % i == 0) {
count++;
product *= i;
temp /= i;
while (temp % i == 0) {
temp /= i; // Remove duplicates of the prime factor
}
}
}
if (count == 3 && product == num) {
System.out.println("Sphenic Number");
} else {
System.out.println("Not a Sphenic Number");
}
}
public static boolean isPrime(int n) {
if (n <= 1) return false;
for (int i = 2; i <= Math.sqrt(n); i++) {
if (n % i == 0) return false;
}
return true;
}
}
Check whether a number is a Buzz number.
Write a program to check whether a number is a Buzz number or not. (A number is Buzz if it ends with 7 or is divisible by 7.)
27
Buzz Number
public class BuzzNumber {
public static void main(String[] args) {
int num = 27;
if (num % 7 == 0 || num % 10 == 7) {
System.out.println("Buzz Number");
} else {
System.out.println("Not a Buzz Number");
}
}
}
Check whether a number is an Evil number.
Write a program to check whether a number is an Evil number. (A number is Evil if it has an even number of 1’s in its binary representation.)
9
Evil Number
public class EvilNumber {
public static void main(String[] args) {
int num = 9;
int countOnes = 0;
int temp = num;
while (temp > 0) {
if ((temp & 1) == 1) {
countOnes++;
}
temp >>= 1;
}
if (countOnes % 2 == 0) {
System.out.println("Evil Number");
} else {
System.out.println("Not an Evil Number");
}
}
}
Validate a 10-digit ISBN number.
Write a program to validate a 10-digit ISBN number.
0306406152
Valid ISBN Number
public class ISBNNumber {
public static void main(String[] args) {
String isbn = "0306406152";
if (isValidISBN(isbn)) {
System.out.println("Valid ISBN Number");
} else {
System.out.println("Invalid ISBN Number");
}
}
public static boolean isValidISBN(String isbn) {
if (isbn == null || isbn.length() != 10) {
return false;
}
int sum = 0;
for (int i = 0; i < 9; i++) {
char ch = isbn.charAt(i);
if (!Character.isDigit(ch)) {
return false;
}
sum += (ch - '0') * (10 - i);
}
char lastChar = isbn.charAt(9);
if (lastChar != 'X' && !Character.isDigit(lastChar)) {
return false;
}
sum += (lastChar == 'X') ? 10 : (lastChar - '0');
return (sum % 11 == 0);
}
}
Check whether a number is a Krishnamurthy number.
Write a program to check whether a number is a Krishnamurthy number.
145
Krishnamurthy Number
public class KrishnamurthyNumber {
public static void main(String[] args) {
int num = 145;
if (isKrishnamurthy(num)) {
System.out.println("Krishnamurthy Number");
} else {
System.out.println("Not a Krishnamurthy Number");
}
}
public static boolean isKrishnamurthy(int num) {
int sum = 0;
int temp = num;
while (temp > 0) {
int digit = temp % 10;
sum += factorial(digit);
temp /= 10;
}
return sum == num;
}
public static int factorial(int n) {
int fact = 1;
for (int i = 2; i <= n; i++) {
fact *= i;
}
return fact;
}
}
Check whether a number is a Bouncy number.
Write a program to check whether a number is a Bouncy number.
155349
Bouncy Number
public class BouncyNumber {
public static void main(String[] args) {
int num = 155349;
if (isBouncy(num)) {
System.out.println("Bouncy Number");
} else {
System.out.println("Not a Bouncy Number");
}
}
public static boolean isBouncy(int num) {
boolean increasing = false;
boolean decreasing = false;
int prevDigit = num % 10;
num /= 10;
while (num > 0) {
int currDigit = num % 10;
if (currDigit < prevDigit) {
increasing = true;
} else if (currDigit > prevDigit) {
decreasing = true;
}
if (increasing && decreasing) {
return true; // Bouncy
}
prevDigit = currDigit;
num /= 10;
}
return false; // Not Bouncy
}
}
Check whether a number is a Mystery number.
Write a program to check whether a number is a Mystery number. (A number is Mystery if it can be expressed as the sum of two numbers and their reverse.)
121
Mystery Number
public class MysteryNumber {
public static void main(String[] args) {
int num = 121;
if (isMystery(num)) {
System.out.println("Mystery Number");
} else {
System.out.println("Not a Mystery Number");
}
}
// Returns reverse of a number
public static int reverse(int n) {
int rev = 0;
while (n > 0) {
rev = rev * 10 + n % 10;
n /= 10;
}
return rev;
}
public static boolean isMystery(int num) {
// Check for any pair (a,b) such that num = a + b + reverse(a) + reverse(b)
for (int a = 0; a <= num; a++) {
for (int b = 0; b <= num; b++) {
int sum = a + b + reverse(a) + reverse(b);
if (sum == num) {
return true;
}
}
}
return false;
}
}
Check whether a number is a Smith number.
Write a program to check whether a number is a Smith number. (A number is Smith if it is a composite number for which the sum of digits equals the sum of digits of its prime factors.)
666
Smith Number
public class SmithNumber {
public static void main(String[] args) {
int num = 666;
if (isSmithNumber(num)) {
System.out.println("Smith Number");
} else {
System.out.println("Not a Smith Number");
}
}
// Function to calculate sum of digits
public static int sumOfDigits(int n) {
int sum = 0;
while (n > 0) {
sum += n % 10;
n /= 10;
}
return sum;
}
// Check if prime
public static boolean isPrime(int n) {
if (n <= 1) return false;
for (int i = 2; i <= Math.sqrt(n); i++) {
if (n % i == 0) return false;
}
return true;
}
// Check Smith Number
public static boolean isSmithNumber(int n) {
if (isPrime(n)) return false; // Smith number must be composite
int originalSum = sumOfDigits(n);
int primeFactorSum = 0;
int temp = n;
// Find prime factors and sum their digits
for (int i = 2; i <= temp; i++) {
while (temp % i == 0) {
primeFactorSum += sumOfDigits(i);
temp /= i;
}
}
return originalSum == primeFactorSum;
}
}
Check whether a number is a Strontio number.
Write a program to check whether a number is a Strontio number. (A number is Strontio if multiplying it by 2 results in a 4-digit number where the middle two digits are the same.)
7694
Strontio Number
public class StrontioNumber {
public static void main(String[] args) {
int num = 7694;
if (isStrontio(num)) {
System.out.println("Strontio Number");
} else {
System.out.println("Not a Strontio Number");
}
}
public static boolean isStrontio(int n) {
int product = n * 2;
String prodStr = String.valueOf(product);
// Check if product is a 4-digit number
if (prodStr.length() != 4) {
return false;
}
// Check if middle two digits are the same
return prodStr.charAt(1) == prodStr.charAt(2);
}
}
Check whether a number is a Xylem or Phloem number.
Write a program to check whether a number is a Xylem or Phloem number. (Xylem: sum of extreme digits = sum of mean digits; otherwise Phloem.)
1234
Phloem Number
public class XylemPhloemNumber {
public static void main(String[] args) {
int num = 1234;
if (isXylem(num)) {
System.out.println("Xylem Number");
} else {
System.out.println("Phloem Number");
}
}
public static boolean isXylem(int n) {
String s = String.valueOf(n);
int length = s.length();
int sumExtreme = s.charAt(0) - '0' + s.charAt(length - 1) - '0';
int sumMean = 0;
for (int i = 1; i < length - 1; i++) {
sumMean += s.charAt(i) - '0';
}
return sumExtreme == sumMean;
}
}
Find the nth prime number.
Write a program to find the nth prime number.
10
29
public class NthPrimeNumber {
public static void main(String[] args) {
int n = 10;
System.out.println(n + "th prime number is: " + findNthPrime(n));
}
public static int findNthPrime(int n) {
int count = 0;
int num = 1;
while (count < n) {
num++;
if (isPrime(num)) {
count++;
}
}
return num;
}
public static boolean isPrime(int number) {
if (number <= 1) return false;
if (number == 2) return true;
for (int i = 2; i <= Math.sqrt(number); i++) {
if (number % i == 0) return false;
}
return true;
}
}
isPrime method.Display alternate prime numbers up to a limit.
Write a program to display alternate prime numbers up to a limit.
20
2, 5, 11, 17
import java.util.ArrayList;
public class AlternatePrimeNumbers {
public static void main(String[] args) {
int limit = 20;
ArrayList primes = new ArrayList<>();
for (int i = 2; i <= limit; i++) {
if (isPrime(i)) {
primes.add(i);
}
}
System.out.print("Alternate primes up to " + limit + ": ");
for (int i = 0; i < primes.size(); i += 2) {
System.out.print(primes.get(i));
if (i + 2 < primes.size()) {
System.out.print(", ");
}
}
}
public static boolean isPrime(int num) {
if (num <= 1) return false;
if (num == 2) return true;
for (int i = 2; i <= Math.sqrt(num); i++) {
if (num % i == 0) return false;
}
return true;
}
}
Find the square root of a number without using the sqrt() method.
Write a program to find the square root of a number without using the sqrt() method.
25
5
public class SquareRootWithoutSqrt {
public static void main(String[] args) {
int num = 25;
double sqrt = 0;
double precision = 0.0001;
// Using binary search to find square root
double low = 0;
double high = num;
while ((high - low) > precision) {
double mid = (low + high) / 2;
if (mid * mid == num) {
sqrt = mid;
break;
} else if (mid * mid < num) {
low = mid;
sqrt = mid;
} else {
high = mid;
}
}
System.out.printf("Square root of %d is %.4f%n", num, sqrt);
}
}
Swap two numbers using the bitwise XOR operator.
Write a program to swap two numbers using bitwise XOR operator.
a = 5, b = 10
a = 10, b = 5
public class SwapUsingBitwiseXOR {
public static void main(String[] args) {
int a = 5, b = 10;
a = a ^ b; // Step 1
b = a ^ b; // Step 2
a = a ^ b; // Step 3
System.out.println("a = " + a + ", b = " + b);
}
}
Find the Greatest Common Divisor (GCD) of two numbers.
Write a program to find the GCD of two numbers.
54, 24
GCD: 6
public class GCDOfTwoNumbers {
public static void main(String[] args) {
int a = 54, b = 24;
int gcd = findGCD(a, b);
System.out.println("GCD: " + gcd);
}
public static int findGCD(int a, int b) {
while (b != 0) {
int temp = b;
b = a % b;
a = temp;
}
return a;
}
}
Find the largest among three numbers.
Write a program to find the largest of three numbers.
10, 25, 15
Largest: 25
public class LargestOfThree {
public static void main(String[] args) {
int a = 10, b = 25, c = 15;
int largest = a;
if (b > largest) {
largest = b;
}
if (c > largest) {
largest = c;
}
System.out.println("Largest: " + largest);
}
}
Find the smallest among three numbers using ternary operator.
Write a program to find the smallest of three numbers using the ternary operator.
10, 25, 5
Smallest: 5
public class SmallestOfThreeTernary {
public static void main(String[] args) {
int a = 10, b = 25, c = 5;
int smallest = (a < b) ? ((a < c) ? a : c) : ((b < c) ? b : c);
System.out.println("Smallest: " + smallest);
}
}
Check whether a given number is positive, negative, or zero.
Write a program to check whether a given number is positive, negative or zero.
-8
Negative Number
public class CheckPositiveNegative {
public static void main(String[] args) {
int num = -8;
if (num > 0) {
System.out.println("Positive Number");
} else if (num < 0) {
System.out.println("Negative Number");
} else {
System.out.println("Zero");
}
}
}
Check whether a number is a perfect square.
Write a program to check whether a number is a perfect square.
49
Perfect Square
public class PerfectSquareCheck {
public static void main(String[] args) {
int num = 49;
int sqrt = (int) Math.sqrt(num);
if (sqrt * sqrt == num) {
System.out.println("Perfect Square");
} else {
System.out.println("Not a Perfect Square");
}
}
}
Display even numbers from 1 to 100.
Write a program to display even numbers from 1 to 100.
1 to 100
2, 4, 6, 8, ..., 100
public class EvenNumbers {
public static void main(String[] args) {
for (int i = 2; i <= 100; i += 2) {
System.out.print(i);
if (i < 100) {
System.out.print(", ");
}
}
}
}
Display odd numbers from 1 to 100.
Write a program to display odd numbers from 1 to 100.
1 to 100
1, 3, 5, 7, ..., 99
public class OddNumbers {
public static void main(String[] args) {
for (int i = 1; i <= 100; i += 2) {
System.out.print(i);
if (i < 99) {
System.out.print(", ");
}
}
}
}
Find the sum of the first n natural numbers.
Write a program to find the sum of the first n natural numbers.
10
Sum: 55
public class SumOfNaturalNumbers {
public static void main(String[] args) {
int n = 10; // Number of natural numbers to sum
int sum = 0;
for (int i = 1; i <= n; i++) {
sum += i;
}
System.out.println("Sum: " + sum);
}
}
The simplest Java program that demonstrates the basic structure of a Java application.
None
Hello, World!
public class HelloWorld - Defines a class named HelloWorld (must match filename)public static void main(String[] args) - The entry point of any Java programSystem.out.println() - Prints the specified message to the consoleA simple program demonstrating variable declaration, assignment, and basic arithmetic in Java.
5, 10
Sum: 15
int num1 = 5; - Declares an integer variable num1 and assigns value 5int num2 = 10; - Declares an integer variable num2 and assigns value 10int sum = num1 + num2; - Adds the two numbers and stores result in sumSystem.out.println() - Prints the result with descriptive textA program that checks whether a given number is even or odd using conditional statements.
7
7 is Odd
int num = 7; - Declares and initializes the number to checknum % 2 == 0 - Uses modulus operator to check divisibility by 2A simple comparison program to find the largest of two given numbers using if-else condition.
8, 12
Largest number: 12
int a = 8, b = 12; - Two integer variables are initializedif(a > b) - Compares whether a is greater than bWrite a program to calculate simple interest using the formula SI = (P × R × T) / 100.
P=1000, R=5, T=2
Simple Interest: 100.0
double P = 1000, R = 5, T = 2; - Principal, Rate and Time are initializedSI = (P * R * T) / 100; - Formula for simple interestSystem.out.println()Write a program to check whether a given year is a leap year.
2024
2024 is a Leap Year
year = 2024; - The year to check.(year % 4 == 0 && year % 100 != 0) || (year % 400 == 0) - Leap year condition.Write a program to swap two numbers without using a third variable.
a=5, b=10
After swapping: a=10, b=5
a = a + b; - Sum of a and b stored in a.b = a - b; - b becomes original a.a = a - b; - a becomes original b.Write a program to find the factorial of a number.
5
Factorial of 5 is 120
fact = 1 and loop from 1 to num.fact with each iterator i.Write a program to reverse a given number.
1234
Reversed number: 4321
num % 10.rev = rev * 10 + digit.Write a program to find the sum of digits of a number.
123
Sum of digits: 6
num % 10 to extract the last digit.sum and remove the last digit using num /= 10.Write a program to check whether a number is prime or not.
7
7 is a Prime Number
num / 2.isPrime = false.isPrime value.Write a program to print the multiplication table of a given number.
5
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50
for loop from 1 to 10.num * i in each iteration.Write a program to find the largest of three numbers.
15, 25, 10
Largest number: 25
a is the largest.b and c with the current largest and update it accordingly.Write a program to check whether a number is a palindrome (same forward and backward).
121
121 is a Palindrome Number
Write a program to print the Fibonacci series up to N terms.
5
Fibonacci Series: 0 1 1 2 3