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,
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.

Store the input number in a variable named x

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

Increment i and assign it to another variable m, i.e.

Multiply i with m and assign the result to another variable i.e.

Check if or not

If step 5 is true then x is Pronic number

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

Repeat Steps 3 to Step 7 until
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 
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; break; } } if(flag == 1) { System.out.println(num +" is a Pronic Number."); } else { 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!