Java Program to Find Prime Numbers in a Range

A number is called a prime number if it has only two divisors, 1 and the number itself. So the only way to express the number as a product of two numbers is,  n = n * 1.  For example, 7 is a prime number while 8 is not since 8 = 2 * 4. […]

Prime Number Checker in Java Using Trial Division

A prime number is a natural number which can only be divided(without leaving a remainder) by 1 and the number itself. For example, number 5 is a prime number since it can be divided by 1 and 5. Number 6 is not a prime since it can be divided by 2 and 3 without leaving […]

Floyd’s triangle in Java

Floyd’s triangle is a is a right angled triangle of natural numbers. Printing Floyd’s triangle is usually given as a programming exercise while learning a new language. It is formed by multiple rows of continuously increasing natural numbers with each row having increasing number of natural numbers. One interesting feature of Floyd’s triangle is that […]

Creating Multiplication Table in Java

A multiplication table is a table of numbers which lists product of a decimal sequence of numbers. For example, a multiplication table of 9 by 9 contains a top most row with values ranging from 1 to 9 and a left most row with values ranging from 1 to 9. The middle cells contains the […]

Celsius to Fahrenheit Conversion in Java

The formula for converting temperature in Celsius to Fahrenheit is, Fahrenheit = (9/5) * Celsius + 32 For example, if the temperature is 35 in Celsius, the equivalent value in Fahrenheit is (9/5) * 35 + 32 = 95 F. The formula for converting temperature in Fahrenheit to Celsius is, Celsius = (5/9) * (Fahrenheit […]