Friday, June 28, 2019

Pronic Number | Programming | Eclipse JAVA | Follow on Youtube for more




import java.util.*;
class Pronic_Number
{
    public static void main1(String []args)
    {
        int num,count=0,d;
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter the number");
        num=sc.nextInt();
        for( int i=1;i<(num/2);i++)//6
        {
            d=i*(i+1);
            if(d==num)
            {
            count=count+1;
            break;
             }
            else
            d=0;
        }
        if(count>0)
        System.out.println(num+" is a pronic number");
        else
        System.out.println(num+" is not a pronic number");
    }
}
/*
 A pronic number is a something which is a product of 2 consecutive numbers.
 
Input  : 6
Output : Pronic Number
Explanation: 6 = 2 * 3 i.e 6 is a product
of two consecutive integers 2 and 3.

Input :56
Output :Pronic Number
Explanation: 56 = 7 * 8 i.e 56 is a product
of two consecutive integers 7 and 8.

Input  : 8
Output : Not a Pronic Number
Explanation: 8 = 2 * 4 i.e 8 is a product of
2 and 4 which are not consecutive integers.
*/


No comments:

Post a Comment

ICSE COMPUTER SCIENCE SPECIMEN PAPER | QUESTION 7 | PLEASE DO WATCH THE VIDEO

  import  java.util.*; class icse_specimen_1 {     public static void main(String[] args)     {         Scanner sc1 = new Scanner(System.in)...