0% found this document useful (0 votes)
9 views

Program 17 PRONIC NUMBER

Uploaded by

aliasgarop123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Program 17 PRONIC NUMBER

Uploaded by

aliasgarop123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Program 17 : PRONIC

NUMBER
__________________________________________________________
_____
import java.util.Scanner;

public class PronicNumber {


public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
int number = sc.nextInt();

boolean isPronic = false;


for (int i = 0; i <= number; i++) {
if (i * (i + 1) == number) {
isPronic = true;
break;
}
}

if (isPronic) {
System.out.println(number + " is a Pronic
number.");
} else {
System.out.println(number + " is not a Pronic
number.");
}
}
}
AlGORITHM
_____________________________________________

 Step 1: Input the integer n.


 Step 2: Initialize a loop variable i starting from 0.
 Step 3: Check if i * (i + 1) equals n.
 If true, output that n is a Pronic number.
 Else, increment i and repeat Step 3.
 Step 4: If the loop completes without finding a
match, output that n is not a Pronic number.
 Step 5: End the process.
OUTPUT
_____________________________________________
Variable Table
_____________________________________________

You might also like