Sunday, June 21, 2020

Write a program to input a number and check whether it is Pronic ( heteromecic ) Number or not?(which is the product of two consecutive integers, that is, n*(n+1) , 110k=(int) Math.sqrt (110), k*(k+1)=110)

25)  Write a program to input a number and check whether it is Pronic ( heteromecic ) Number or not?(which is the product of two consecutive integers, that is, n*(n+1) , 110,k=(int) Math.sqrt (110), k*(k+1)=110

import java.util.*;

public class pronic_number

{

    public static void main(String args[ ])

    {

        Scanner sc = new Scanner (System.in);

        System.out.println("Enter a number");

        int a = sc.nextInt();

        int c = (int)Math.sqrt(a);

        int d = c*(c+1);

        if(d==a)

        {

            System.out.println(a+" is a PRONIC number");

        }

        else

        {

            System.out.println(a+" is not a PRONIC number");

        }

    }

}

No comments:

Post a Comment

if you have any doubts, Please let me know.
Your Truly
Shashank Porwal

 jhvghvgk ;nkjn ,nkjhj