Pronic Number in Java: Definition, Explanation, Examples, and Practice Problems

Learn what a Pronic Number is in Java with clear explanations, examples, and a complete Java program. Understand how to identify Pronic Numbers and practice with 3 coding challenges.

Pronic Number in Java: Definition, Explanation, Examples, and Practice Problems

A Pronic Number (also called a Rectangular Number or Oblong Number) is a number that is the product of two consecutive integers. These numbers appear in many mathematical problems and are a common topic in programming exercises involving number patterns.

What Is a Pronic Number?

A number N is a Pronic Number if it can be written as:

N = n × (n + 1)

That means the number is formed by multiplying two consecutive integers.

Examples of Pronic Numbers

  • 0 = 0 × 1
  • 2 = 1 × 2
  • 6 = 2 × 3
  • 12 = 3 × 4
  • 20 = 4 × 5
  • 30 = 5 × 6
  • 42 = 6 × 7

How to Check if a Number Is Pronic?

Steps:

  1. Loop from i = 0 up to the number.
  2. Check if i × (i + 1) equals the number.
  3. If yes → it is a Pronic Number.
  4. If no match is found → not a Pronic Number.

Java Program to Check Pronic Number


import java.util.*;

public class PronicNumber {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a number: ");
        int num = sc.nextInt();

        boolean isPronic = false;

        for (int i = 0; i * (i + 1) <= num; i++) {
            if (i * (i + 1) == num) {
                isPronic = true;
                break;
            }
        }

        if (isPronic) {
            System.out.println("Pronic Number");
        } else {
            System.out.println("Not a Pronic Number");
        }
    }
}

  

Examples Table

Number Expression Pronic?
6 2 × 3 Yes
20 4 × 5 Yes
56 7 × 8 Yes
15 Not applicable No
30 5 × 6 Yes

3 Practice Challenges

Challenge 1: List Pronic Numbers

Write a Java program to print all Pronic Numbers between 1 and 10,000.

Challenge 2: Pronic Count in Array

Given an array of integers, count how many of them are Pronic Numbers.

Challenge 3: Next Pronic Number

Write a Java program to find the next Pronic Number after a given number.