We are uploading our contents, please refresh app.
Java Premium

write a program in java input a number and check Pronic Number (Heteromecic Number) or not.

Question:
Write a Program in Java to input a number and check whether it is a Pronic Number or Heteromecic Number or not.

Pronic Number : A pronic number, oblong number, rectangular number or heteromecic number, is a number which is the product of two consecutive integers, that is, n (n + 1).

The first few pronic numbers are:
0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380, 420, 462 … etc.


Programming Code:
import java.util.*;
class Pronic_Number
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a number : ");
        int n = sc.nextInt();
        int k = (int)(Math.sqrt(n));
        if(k*(k+1)==n)
            System.out.println(n+" is a Pronic Number.");
        else
            System.out.println(n+" is not a Pronic Number.");      
    }
}

Output:
Enter a number : 73
73 is not a Pronic Number.
 
Enter a number : 342
342 is a Pronic Number.
 
Enter a number : 15
15 is not a Pronic Number.

Online user

Download our android app Download App Submit your query
x

Get Updates On

Java & Premium Programs

Java Solved & Questions

Java Coding easy to use

Proper Coding

Straight Into Your INBOX!

We are going to send you our resources for free. To collect your copy at first, join our mailing list. We are promising not to bother you by sending useless information. So don't miss any updates, stay connected!