×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
Sum of the Border elements of 2D Array Harshad Number or Niven Number
Pronic Number - java - Java
6210    Arnab De    09/12/2018

Write a program to input a number and check and print whether it is a Pronic number or not. (Pronic number is the number which is the product of the two consecutive integers)

Examples    

12 = 3 x 4

20 = 4 x 5

42 = 6 x 7

This is very interesting program, which I found in the ICSE 2018 Computer Application paper. We can use different logic to execute the same but here I am use a very easy logic. Just find out the square root of the number and get the integer part. Now find out the multiplication of the integer part and the next number of the integer part. Now compare it with the actual number. If it is equal then print a positive message otherwise print a negative message. Pronic number is also known as Heteromecic Number.

softetechnologies
import java.util.*;
public class Pronic
{
    public static void main(String []args)
    {
        Scanner sc=new Scanner(System.in);
        System.out.print("Enter a Number : ");
        int no=sc.nextInt();
        int k=(int)Math.sqrt(no);
        if(no==(k*(k+1)))
        {
            System.out.println("It is a Pronic No.");
        }
        else
        {
            System.out.println("It is not a Pronic No.");
        }
    }
}
softetechnologies
Sum of the Border elements of 2D Array Harshad Number or Niven Number
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Rabindranath Tagore
The biggest changes in a women's nature are brought by love; in man, by ambition
Rabindranath Tagore
1991
60.42
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     44655
01/01/2018     36856
25/06/2018     36685
28/06/2017     34875
02/08/2017     33472
01/08/2017     27830
06/07/2017     27599
15/05/2017     27166
14/07/2017     22912
11/09/2018     21630
softetechnologies