pronic number:
A pronic
number is
a number which is the product of two consecutive integers, that is, a
number of the form n(n +
1). The
study of these numbers dates back to Aristotle.
They are also called oblong
numbers, heteromecic
numbers, or rectangular
numbers; however,
the "rectangular number" name has also been applied to
the composite
numbers.
The
first few pronic numbers are:
/* program to find given number is pronic number or not*/
import java.util.*;
class PronicNumber
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number : ");
int n = sc.nextInt();
int flag = 0;
for(int i=0; i<n; i++)
{
if(i*(i+1) == n)
{
flag = 1;
break;
}
}
if(flag == 1)
System.out.println(n+" is a Pronic Number.");
else
System.out.println(n+" is not a Pronic Number.");
}
}
OUTPUT:
Enter a number : 420 420 is a Pronic Number. Enter a number : 13 13 is not a Pronic Number. Enter a number : 12 12 is a Pronic Number. Enter a number : 21 21 is not a Pronic Number |
No comments:
Post a Comment