WAP in Java to check whether a number is niven number or not

import java.util.*; class Harshad_Number_or_Niven_no { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int a,r,s=0,t; System.out.println("Enter the no."); a=sc.nextInt(); t=a; while(a>0) { r=a%10; s=s+r; a=a/10; } if(t%s==0) System.out.println("niven no."); else System.out.println("not niven no."); } }

Comments