Monday, 6 January 2020

HAY THANK FOR VISIT

<<<<<<LET'S START WITH ANOTHER QUESTION>>>>>>>>>>>>>

QUESTION --- TO CHECK THAT THE GIVEN NUMBER IS PERFECT NUMBER OR NOT.

class Perfect
{
    void main(int n)
    {
        int f=0;
        for(int i=1;i<n;i++)
        {
            if(n%i==0)
            f=f+i;
        }
        if(f==n)
        System.out.println("perfect number");
        else
        System.out.println("not a perfect number");
    }
}


INPUT--6
OUTPUT--


No comments:

Post a Comment

HAY THAKYOU FOE VISIT

Program(python):-Find duplicates in an array (Geeks for geek problem)

QUESTION:- Given an array  a  of size  N  which contains elements from  0  to  N-1 , you need to find all the elements occurring more than o...