Write a Java program to check whether the given number in Pronic or not.

A Pronic number is that number which can be represented as a product of two consecutive number (i.e n*(n+1)). Eg 6, 12, 20, etc.

Pronic numbers

A pronic number is also known as Rectangular number or Oblong number.

So to check pronic number in java, we first need to find the square root (n) of the given number or number nearest to the square root because the product of two consecutive number is close to the square of one of the numbers.

Compute the product with the next number (n+1). If the product is equal to the original number then it is pronic else not.

Output

Print all Pronic Numbers in Given Range

All we need to do is to loop through each number in the given range and check each of the number using the same approach as specified in the above program.

Output

All Pronic numbers from 1 to 100

Comment below your suggestion or doubts.

Leave a Reply

Close Menu