Deficient Number

 //Wap to accept a number and check it is Deficient number or not.

//A number is said to be a Deficient number if sum of the factors of the number is less than the number.

import java.util.*;

class deficient

{//class deficient opens

    public static void main(String[]args)

    {//main method opens

        Scanner sc=new Scanner(System.in);

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

        int n=sc.nextInt();//variable n to accept the no

        int s=0;//variable s to store the sum of the factors

        for(int i=1;i<n;i++)

        {

            if(n%i==0)

            s=s+i;

        }

        if(s<n)

        System.out.println("It is a deficient no");

        else

        System.out.println("It is not a deficient no");

    }//main method closes

}//class closes


No comments:

Post a Comment

any problem in any program comment:-

Mersenne Number

  Write a program to check if a number is a Mersenne number or not. In    mathematics , a Mersenne number is a number that can be written in...