Java Program to Find LCM of two Numbers In this program, you’ll learn to find the lcm of two number by using GCD, and by not using GCD. This is done using for and while loops in Java. The LCM of two integers is the smallest positive integer that is perfectly divisible by both …
Java Program to Find GCD of two Numbers In this program, you’ll learn to find GCD of two numbers in Kotlin. This is done by using for and while loops with the help of if else statements. The HCF or GCD of two integers is the largest integer that can exactly divide both numbers …
Java Program to Display Fibonacci Series In this program, you’ll learn to display fibonacci series in Java using for and while loops. You’ll learn to display the series upto a specific term or a number. The Fibonacci series is a series where the next term is the sum of the previous two terms. The …
Java Program to Generate Multiplication Table In this program, you’ll learn to generate multiplication table of a given number. This is done by using a for and a while loop in Java. Example 1: Generate Multiplication Table using for loop public class MultiplicationTable{ public static void main(String[] args){ int num = 5; for(int i …
Java Program to Find Factorial of a Number In this program, you’ll learn to find the factorial of a number using for and while loop in Java. The factorial of a positive number n is given by: factorial of n (n!) = 1 * 2 * 3 * 4 * … * n Example 1: …
Java Program to Calculate the Sum of Natural Numbers In this program, you’ll learn to calculate the sum of natural numbers using for loop and while loop in Java. The positive numbers 1, 2, 3… are known as natural numbers and its sum is the result of all numbers starting from 1 to the …
Java Program to Check Whether a Character is Alphabet or Not In this program, you’ll learn to check whether a given character is an alphabet or not. This is done using an if else statement or a ternary operator in Java. Example 1: Java Program to Check Alphabet using if else public class Alphabet{ …
Java Program to Check Whether a Number is Positive or Negative In this program, you’ll learn to check whether a given number is positive or negative. This is done by using a if else statement in Java. Example: Check if a Number is Positive or Negative using if else public class PositiveNegative{ public static …
Java Program to Check Leap Year In this program, you’ll learn to check if the given year is a leap year or not. This is checked using a if else statement. A leap year is exactly divisible by 4 except for century years (years ending with 00). The century year is a leap year …
Java Program to Find all Roots of a Quadratic Equation In this program, you’ll learn to find all roots of a quadratic equation and print them using format() in Java. The standard form of a quadratic equation is: ax2 + bx + c = 0, where a, b and c are real numbers and a …