find all pronic numbers in a given range.

(The pronic number can be defined as the number which is a product of two consecutive numbers. )

Share code with your friends

Share on whatsapp
Share on facebook
Share on twitter
Share on telegram


					import java.util.Scanner;
public class PronicNumbersInGivenRange  
    /*isPronicNumber() will determine whether a given number is pronic number or not*/  
    public static boolean isPronicNumber(int num)
        boolean flag = false;  
        for(int j = 1; j <= num; j++)
            /* Checks for pronic number by multiplying consecutive numbers */  
            if((j*(j+1)) == num)
                flag = true;  
        return flag;  
    public static void main(String[] args) 
        int lowerRange=0,upperRange=0,i=0;  
        Scanner sc = new Scanner(;
        System.out.println("Enter the lower range");
        System.out.println("Enter the Upper range");
        //Displays pronic numbers between lowerRange and upperRange  
        System.out.println("Pronic numbers between "+lowerRange+" and "+upperRange);  
        for(i = lowerRange; i <=upperRange; i++)
                System.out.print(i + " ");  


Coding Store

Leave a Reply

Your email address will not be published. Required fields are marked *