An easy Pronic Number Program
Pronic Number Program: solved Java program for ICSE Class 9 Computer Applications with complete BlueJ code, explanation and sample output.
It is a number which is the product of two consecutive integers, that is, a number of the form n(n + 1).
For Example: 12 is a pronic number because it is a result of -> 3*(3+1) =3*4= 12
For other number related programs check the given link
Unleashed: Important Number Programs for ICSE Part-1
Write a program to accept a number and check whether the number is a pronic number or not.
import java.io.*;
class pronic //the product of consecutive integers e.g., 72, 110
{
public static void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out .println("Enter a number");
int num=Integer.parseInt(br.readLine());
int ans=0;
for(int i=0;i<num;i++)
{
if(i*(i+1)==num)
{
ans=1;
break;
}
}
if(ans==1)
{
System.out.println("It is a pronic number");
}
else
{
System.out.println("It is not pronic number");
}
}
}Output:
Enter a number
12
It is a pronic number
Watch the video to learn more about java
https://www.youtube.com/watch?v=QZKcULOC4lg
Related Posts
Continue learning with these related articles
Sum of First n Natural Numbers in Java (Loop and Formula)
Find the sum of the first n natural numbers in Java with a for loop, a while loop and the formula n(n + 1)/2, with a dry run and the sums of even numbers, odd numbers, squares and cubes.
Prime Number Program in Java: Check a Number and Print Primes in a Range
Check whether a number is prime in Java by counting its factors, a faster square-root method with isPrime(), and a program that prints all prime numbers in a range.

Encapsulation, Access Specifiers and Scope of Variables in Java for ICSE Class 10
ICSE Class 10 Computer Applications notes on encapsulation: private, default, protected and public access, data hiding with getter and setter methods, instance vs static (class) variables, local variables and scope, with a solved BankAccount program.