What is Pronic Number? And More…

Share with Friends:

In Section B of ICSE 2018 Computer Application paper, a Question of 15 marks was asked. Students were expected to write a Java program to check whether an input number was a Pronic number or not. The actual question appeared in the following form:

Section B, Question 5: Write a program to input a number and check and print whether it is a Pronic number or not. (Pronic number is the number which is the product of two consecutive integers)

Examples: 12=3×4, 20=4×5, 42=6×7

Before getting into programming, let us first develop our understanding of Pronic numbers. Pronic numbers are also called oblong numbers, heteromecic numbers, or rectangular numbers. Examples of first few pronic numbers are: 0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156. Consider number 12 from examples given in the question above. Factors of number 12 are: 1,2,3,4,6,12 (total six numbers). Out of 6 numbers let us pick a unique pair of numbers which when multiplied together give 12 as result. The pair of numbers would be:

1×12, 2×6, 3×4

Now, carefully examine the factor pairs in light of the definition given in the question. Clearly, there is only one factor pair comprising numbers which are consecutive integers. It is the third pair of factors which contains consecutive integers 3 and 4. All other pairs do not make number 12 Pronic despite being the factor pairs because, on a number line, one does not appear immediately after the other. So, in other words, out of the three factor pairs for number 12 only one factor pair ( i.e. 3 and 4) qualifies number 12 as Pronic.

Now, consider number 27 and find out if it qualifies as Pronic. First, list the factors of 27, which are; 1,3,9,27 (total four numbers). Next, create unique pair of numbers which when multiplied together give 27 as output. The numbers pairs are: 1×27, 3×9. So we have 2 factor pairs for the number in consideration. A quick examination shows that none of the pairs comprises numbers which are consecutive integers.Therefore, we conclude that number 27 does not qualify to be Pronic.

From above exercise we can say that if n is an Integer then result obtained by multiplying it with (n+1) will be a Pronic number. Mathematically, we may write,

Pronic number, n_{p}=n(n+1)

Conversely, as asked in the question above, in order to find out whether a given number is Pronic or not; we need to generate consecutive base integers starting from zero, increment it by one, multiply the new number thus obtained with its base number and thereafter check if the result obtained is equal to the number in question. This step is repeated until the condition is reached and/or until the base integer generated is less that the given number.

Let us write down the statements in the above paragraph in steps for better understanding. It will also insure that we correctly understand the Java code which is presented thereafter.

  1. Store the input number in a variable named x

  2. Take a variable i and assign value zero to it, i.e. i=0

  3. Increment i and assign it to another variable m, i.e. m=i+1

  4. Multiply i with m and assign the result to another variable n_{p} i.e. n_{p} =i\times m

  5. Check if n_{p} = x or not

  6. If step 5 is true then x is Pronic number

  7. Else, if Step 5 is false then increment i by one

  8. Repeat Steps 3 to Step 7 until i < x

Implementation of above steps in Java Programming Language is given below. If you are interested to compile the code and run it on your computer please insure that you have latest BlueJ software installed. You may download BlueJ for Windows 7 or later by clicking this link → Download BlueJ. If you wish to work like a professional Java programmer you may consider using IDEs like Netbeans, Eclipse or IntelliJ IDEA.

import java.util.Scanner;

public class CheckPronic {

    public static void main(String args[])
        Scanner sc = new Scanner(System.in);
        System.out.print("Input a number : ");
        int x = sc.nextInt();
        int flag = 0;
        for(int i=0; i<x; i++)
          int m=i+1;   
          int np=i*m; 

          if(np == x)
                flag = 1;
        if(flag == 1)
            System.out.println(num +" is a Pronic Number.");
            System.out.println(num + " is Not a Pronic Number.");  

Hope you enjoyed reading this article as much as I have enjoyed writing it for you. Please leave your valuable comments and remember to subscribe and share by choosing the button(s) below. We have several interesting contents lined up for release.

Have a nice day!

Share with Friends:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.