1.

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 two consecutive integers)Example : 12 = 3 x 4              20 = 4 x 5               42 = 6 x 7

Answer»

import java.io.*;

class PronicNum

{

public static void main(string args[])

{

Buffered Reader br= new Buffered Reader(new Input Stream Reader(System.in)); System. out.println("Enter one number ");

int n= Integer. parseInt (br.readLine());

int i;

for(i=1; i*(i+1)<=n ; i++)

{

if(n==i*(i+1))

{

System.out.println(n+" is Pronic Number");

break;

}

}

System.out.println(n+ " is not Pronic Number");

}



Discussion

No Comment Found

Related InterviewSolutions