Programming Examples

Java program to input a number and check and print whether it is a Pronic number or not


Write a program to input a number and check and print whether it is a Pronic number or not.

Pronic Number : A pronic number, oblong number, rectangular number or heteromecic number, is a number which is the product of two consecutive integers, that is, n (n + 1). The first few pronic numbers are:

0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380, 420, 462 … etc.

Solution

import java.util.*;
class PronicNumber
{
	public static void main(string arr[])
	{
		Scanner sc=new Scanner(System.in);
		int n,i,f=0;
		System.out.println(“Enter a number:”);
		n=sc.nextInt();
		for(i=1;i*(i+1)<=n;i++)
		{
			if(i*(i+1)==n)
			{
				System.out.println(“Pronic Number”);
				f=1;
			}
		}
		if(f==0)
			System.out.println(“Not a pronic number”);
	}
}
Output

Enter a number : 110

110 is a Pronic Number.

Enter a number : 73

73 is not a Pronic Number.

Enter a number : 342

342 is a Pronic Number.

Enter a number : 15

15 is not a Pronic Number.

Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2025 Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz