Q- WAP TO CHECK IF A NUMBER IS PRONIC OR NOT?

import java.io.*; 
class PRONIC
{
public static void main(String args[]) throws IOException
{
int n=0;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Number");
n=Integer.parseInt(br.readLine());
int k=0,p=0;
for(int i=1;i<=n;i++)
{
p=i*(i+1);
if(p==n)
k=1;
}
if(k==1)
System.out.println("PRONIC NUMBER");
else
System.out.println("NOT PRONIC NUMBER");
}
}

Advertisements

One thought on “Q- WAP TO CHECK IF A NUMBER IS PRONIC OR NOT?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s