Program To Print Pronic Number JAVA


Write a Program to print whether the inputted number is Pronic or not.




[ A number is said to be a pronic number if product of two consecutive integers is equal to the number, is called a pronic number. Example : 12 = 3x4, 42 = 6x7]


import java.util.*;
class pronic
   {
    public static void main(String args[])
    {
     Scanner sc = new Scanner (System.in);
     int n = sc.nextInt();
     int flag = 0;
     for (int i =0; i< n;i++)
     {
        if(i *(i + 1)== n)
        {
          flag = 1;
          break;
        }
     }
     if (flag == 1)
     {
         System.out.println("It is pronic no");
     }
     else
     {
       System.out.println("It is not pronic no");  
     }
     
   }
}

     
                     

Contact Us

REACH US

SERVICES

  • CODING
  • ON-LINE PREPARATION
  • JAVA & PYTHON

ADDRESS

B-54, Krishna Bhawan, Parag Narain Road, Near Butler Palace Colony Lucknow
Contact:+ 919839520987
Email:info@alexsir.com