Write a program to input a number and print whether it is an ‘X’ Number or not( A number is said to be an ‘X’ number when it is a product of 2 consecutive integers Eg: 6=2x3 , 12 =3*4 , 56=7*8 )
write in Java and please don't spam
it's urgent please answer
Answers
Answered by
1
Answer:
import java.util.Scanner;
public class KboatPronicNumber
{
public void pronicCheck() {
Scanner in = new Scanner(System.in);
System.out.print("Enter the number to check: ");
int num = in.nextInt();
boolean isPronic = false;
for (int i = 1; i <= num - 1; i++) {
if (i * (i + 1) == num) {
isPronic = true;
break;
}
}
if (isPronic)
System.out.println(num + " is a pronic number");
else
System.out.println(num + " is not a pronic number");
}
}
Explanation:
Mark Me Brainliest.
Similar questions