Computer Science, asked by AdnanQuraishi99, 4 months ago

write a program to input a number and check and print whether it is a pronic number or not.​

Answers

Answered by anindyaadhikari13
1

Question:-

Write a program to input a number and check whether it is a pronic number or not.

A number is said to be a pronic number if it is equal to product of two consecutive integers.

Program:-

Here is your program

import java.util.*;

class Pronic

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.print("Enter the number: ");

int n=sc.nextInt();

boolean x=false;

for(int i=1;i<=n;i++)

{

if(i*(i+1)==n)

{

x=true;

break;

}

}

if(x)

System.out.println("Number is a pronic number.");

else

System.out.println("Given number is not a pronic number.");

}

}

Similar questions