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
https://java4school.com/important-number-programs-icse-part-4

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here