Write a program in Java to check a given number is PRONIC number or not .
A pronic number is a number which is the product of two consecutive integers, that is, a number of
the form n(n + 1).
Input - 12= 3"4, so 12 is a PRONIC number.
Answers
Answered by
0
Answer:
mport java.util.*;
public class JavaHungry {
public static void main(String args[]) {
System.out.println("Enter input number ");
Scanner sc = new Scanner(System.in);
int inputNumber = sc.nextInt();
int sqrtNum = (int) Math.sqrt(inputNumber);
int product = sqrtNum * (sqrtNum + 1);
if (product == inputNumber)
System.out.println("Pronic Number");
else
System.out.println("Not a Pronic Number")
Explanation:
Similar questions