Niven number-Java program code for niven number

This is my program code for Niven number and it does meet all the criteria for your icse/any exam



import java.util.*;
public class niven
{
    public static void main (String args[])
    {
        Scanner in = new Scanner (System.in);
        int num,sum=0,d;
        System.out.println("Enter number");
        num=in.nextInt();
        while(num>0)
        {
            d=num%10;
            sum=sum+d;
            num=num/10;
        }
        if(num%sum==0)
        System.out.println("niven");
        else
        System.out.println("not niven");
    }
}

Comments

Popular posts from this blog

Practice questions for English grammar

Physics 2017 Solved Paper Physics

Computer applications icse board exam paper solved 2017