# Pronic number in java

Let’s learn pronic number in java.

## Pronic number in java

Pronic number is a number which is product of two consecutive integers. Number in the form “n * (n + 1)”. Pronic numbers is also called as rectangular numbers, oblong numbers and heteromecic numbers.

For example:

7 * 8 = 56 is pronic number

Here 7 and 8 are consecutive integers.

Another example:

8 * 9 = 72

Here 8 and 9 are consecutive integers.

Here are pronic numbers upto 500 – 0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380, 420, 462.

Now let’s see pronic number program.

import java.util.Scanner;
public class PronicNumberJava
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int number = sc.nextInt();
int pronic = 0;
for(int p = 0; p < number; p++)
{
if(p * (p + 1) == number)
{
pronic = 1;
break;
}
}
if(pronic == 1)
{
System.out.println(number + " is a pronic number.");
}
else
{
System.out.println(number + " is not a pronic number.");
}
sc.close();
}
}

Output:

342 is a pronic number.

240 is a pronic number.

400 is not a pronic number.