Computer Science, asked by parasgoyal0201, 10 months ago

Enter a number and check if it is a Niven number or not ( A number is Niven when it is equal to sum of digits of its square) Plz use JAVA method

Answers

Answered by omegads03
0

for i=n;

{

 If

   i= 2; i<=n i++;

  cin<< \n The number is  \n >>

  cout <<The number is \n >>

else

  {

   i=1 ; i<=n; i--:

}

}

 

Answered by Anonymous
0

import java.util.*;

class niven_number

{

   public void main()

   {

       Scanner sc=new Scanner(System.in);

       System.out.println("Enter a number to check whether it is a niven number or not");

       int n=sc.nextInt();

       int d=0;

       int s=0;

       int cpy=n;

       while(n>0)

       {

           d=n%10;

           s=s+d;

           n=n/10;

       }

       if(cpy%s==0)

       {

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

       }

       else

       {

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

       }

   }

}

Similar questions